我想從request.form [「file」]寫入文件,但我無法做到。如何通過燒瓶從客戶端寫入png文件到目標目錄
我的contact.html在這裏。
客戶端代碼是這個樣子......
<form action="contact" method="POST" enctype="multipart/form-data">
<input type="file" name="file">
<input type="submit" value="submit">
</form>
服務器端是這樣
filestorage = request.files["file"]
print type(_file) #-> <FileStorage: u"__proto.png" ("img/png")>
# I tried below this , but it doesn't work.
f = open("tmp.png","wb")
f.write(filestorage)
我想寫這裏面是什麼地方png文件到上傳的文件。你有什麼主意嗎?
在此先感謝。