开发者

In Python + Pylons, simple way to copy uploaded file to disk

How can I copy a posted file to disk?

Can I do something like:

file = '/uploaded_开发者_开发百科files/test.txt'
shutil.copy2(request.POST['file'],file)

Thanks.


You do something like this:

tempfile = request.POST['file']
file_path = 'uploaded_files/' + tempfile.filename # for the original filename
permanent_file = open( file_path, 'wb')
shutil.copyfileobj(tempfile.file, permanent_file)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜