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)
精彩评论