0

I am trying to make a web application sing flask in python3. to do so, I am using the following code to upload the files and save them in a folder:

app = Flask(__name__)
Bootstrap(app)
db = SQLAlchemy(app)

# Configuration for File Uploads
files = UploadSet('files',ALL)
app.config['UPLOADED_FILES_DEST'] = 'static/uploadsDB'
configure_uploads(app,files)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///static/uploadsDB/filestorage.db'

# Saving Data To Database Storage
class FileContents(db.Model):
    id = db.Column(db.Integer,primary_key=True)
    name = db.Column(db.String(300))
    modeldata = db.Column(db.String(300))
    data = db.Column(db.LargeBinary)


@app.route('/')
def index():
    return render_template('index.html')


@app.route('/dataupload',methods=['GET','POST'])
def dataupload():
    if request.method == 'POST' and 'csv_data' in request.files:
        file = request.files['csv_data']
        filename = secure_filename(file.filename)
        file.save(os.path.join('static/uploadsDB',filename))
        fullfile = os.path.join('static/uploadsDB',filename)

but the problem is that I can not upload all the files at the same time and every time I have to go back to the previous page and upload the next file and this makes problem. how can I fix this problem to be able to upload all the files together?

davidism
  • 121,510
  • 29
  • 395
  • 339
elly
  • 317
  • 1
  • 2
  • 11
  • Are the files getting uploaded? If yes, then your problem might be with how you are handling the click on your `submit` button – Mortz Sep 11 '19 at 13:22
  • @Mortz: yes they are uploaded but every time I can upload only one of them. but I want to choose all of them and also upload all of them at the same time. this is the problem basically. – elly Sep 11 '19 at 13:25

0 Answers0