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.
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)