Re: [問題] python 檔案上傳

看板Python作者 (非常念舊)時間10年前 (2015/01/21 13:47), 10年前編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/2 (看更多)
upload.html: <html> <body> <form action=upload_file_form method="post"> <input type="file" name="file"></br> <input type="submit" value="Send"> </form> </body> </html> 主程式.py: UPLOAD_FOLDER='/home/bernie/flask_web_demaon/ovpn_files' @app.route("/upload_file_form",methods=['GET','POST']) def upload_file_form(): import os file = request.files['file'] filename = secure_filename(file.filename) file.save(os.path.join(app.config['UPLOAD_FOLDER'],filename)) return send_from_directory('static/report/flexmonkey/html','upload.html' 就可以了,謝謝。 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 211.21.170.157 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1421819257.A.60B.html ※ 編輯: gn00618777 (211.21.170.157), 01/21/2015 13:49:26
文章代碼(AID): #1KlprvOB (Python)
文章代碼(AID): #1KlprvOB (Python)