示例#1
0
def image_upload():
    if request.method == 'POST':
        form = ImageForm(request.form)
        if form.validate():
            image_file = request.files['file']
            filename = os.path.join(app.config['IMAGES_DIR'], secure_filename(image_file.filename))
            image_file.save(filename)
            flash('Saved %s' % os.path.basename(filename), 'success')
            return redirect(url_for('entries.index'))
    else:
        form = ImageForm()
    return render_template('entries/image_upload.html', form=form)
示例#2
0
def image_upload():
    if request.method == 'POST':
        form = ImageForm(request.form)
        if form.validate():
            image_file = request.files['file']
            filename = os.path.join(app.config['IMAGES_DIR'],
                                    secure_filename(image_file.filename))
            image_file.save(filename)
            flash('Saved %s' % os.path.basename(filename), 'success')
            return redirect(url_for('entries.index'))
    else:
        form = ImageForm()
    return render_template('entries/image_upload.html', form=form)
示例#3
0
def image_upload():
    if request.method == "POST":
        form = ImageForm(request.form)
        if form.validate():
            image_file = request.files["file"]
            filename = os.path.join(app.config["IMAGES_DIR"], secure_filename(image_file.filename))
            image_file.save(filename)
            flash("Saved %s" % os.path.basename(filename), "success")
            return redirect(url_for("entries.index"))
    else:
        form = ImageForm()

    return render_template("entries/image_upload.html", form=form)