title: permission denied AWS EC2 file.save from Flask App
body: <p>I am writing an application in Flask and am deploying it in EC2. I am trying to make the user upload files in the local directory. But I get a permission denied error when The uploaded file is being saved. I am attaching the code below. pls do help me fix it. I have tried to change the folder permissions to sudo chmod -R 777 /var/www but that doesn't help. I do understand giving write permissions is bad but this for development mode and hoping to get it through 
  this is the code </p>
  
  <pre><code>@app.route('/upload', methods=['GET', 'POST'])
           def upload_file():
          # Get the name of the uploaded files
          uploaded_files = request.files.getlist("file[]")
          filenames = []
          for file in uploaded_files:
          # Check if the file is one of the allowed types/extensions
           if file and allowed_file(file.filename):
          # Make the filename safe, remove unsupported chars
          filename = secure_filename(file.filename)
          # Move the file form the temporal folder to the upload
          # folder we setup
          current_date = time.strftime("%x").split("/")           [0]+time.strftime("%x").split("/")[1]+time.strftime("%x").split("/")[2]
          directory = os.path.join('loadedfiles/')
          uploadedfilesdir = directory + current_date
          if not os.path.exists(uploadedfilesdir):
              os.makedirs(uploadedfilesdir)
          file.save(os.path.join(uploadedfilesdir, filename)) 
          # Save the filename into a list, we'll use it later
          filenames.append(filename)
          # Redirect the user to the uploaded_file route, which
          # will basicaly show on the browser the uploaded file
  # Load an html page with a link to each uploaded file
  return render_template('upload.html', filenames=filenames)
  </code></pre>