I followed this tutorial but am unable to get a file to upload to the directory I want. It says it was succesful, but the file is not in the directory it's supposed to be.
Update I changed my views.py to try and fix the directory call but now I get this error:
File "/home/jsnyder10/Documents/45/app/views.py", line 33, in uploader f.save(os.path.join(app.config['UPLOAD_FOLDER']),secure_filename(f.filename)) IOError: [Errno 21] Is a directory: '/home/jsnyder10/Documents/45/uploads' views.py
@app.route('/mobility_import_html') @login_required def mobility_import_html(): return render_template('mobility_import_html.html') @app.route('/uploader', methods = ['GET', 'POST']) def uploader(): if request.method == 'POST': f = request.files['file'] #f.save(secure_filename(f.filename)) f.save(os.path.join(app.config['UPLOAD_FOLDER']),secure_filename(f.filename)) print("f.filename", f.filename) return 'success' mobility_import_html.html
{% extends "mobility.html" %} {% block mobility %} <form action ="{{ url_for('uploader') }}" method = "POST" enctype = "multipart/form-data"> <input type = "file" name = "file" /> <input type = "submit"/> </form> {% endblock %} init.py
import os from flask import Flask from flask.json import JSONEncoder from flask_sqlalchemy import SQLAlchemy from flask_login import LoginManager from flask_mail import Mail from flask_babel import Babel, lazy_gettext from config import basedir, ADMINS, MAIL_SERVER, MAIL_PORT, MAIL_USERNAME, \ MAIL_PASSWORD from .momentjs import momentjs app.config["UPLOAD_FOLDER"] = os.path.join(basedir, 'uploads')