flask dropzone并行上传(flask 78)

app.py

import os

from flask import Flask, render_template, request
from flask_dropzone import Dropzone

basedir = os.path.abspath(os.path.dirname(file))

app = Flask(name)

app.config.update(
UPLOADED_PATH=os.path.join(basedir, 'uploads'),
# Flask-Dropzone config:
DROPZONE_ALLOWED_FILE_TYPE='image',
DROPZONE_MAX_FILE_SIZE=3,
DROPZONE_MAX_FILES=30,
DROPZONE_PARALLEL_UPLOADS=3, # set parallel amount
DROPZONE_UPLOAD_MULTIPLE=True, # enable upload multiple
)

dropzone = Dropzone(app)

@app.route('/', methods=['POST', 'GET'])
def upload():
if request.method == 'POST':
for key, f in request.files.items():
if key.startswith('file'):
f.save(os.path.join(app.config['UPLOADED_PATH'], f.filename))
return render_template('index.html')

if name == 'main':
app.run(debug=True)

index.html





Flask-Dropzone Demo: Parallel Upload
{{ dropzone.load_css() }}
{{ dropzone.style('border: 2px dashed #0087F7; margin: 10%; min-height: 400px;') }}


{{ dropzone.create(action='upload') }}
{{ dropzone.load_js() }}
{{ dropzone.config() }}

你可能感兴趣的:(flask dropzone并行上传(flask 78))