How to upload file using python.
first of all create an html form using following code:
creat a file with .py extention using following code:
Tags:
Python
<html><body> <form enctype = "multipart/form-data" action = "python_upload.py" method = "post"> <p>Upload File: <input type = "file" name = "filenameupload" /></p> <p><input type = "submit" value = "Upload" /></p></form></body></html>import osfileitem = form['filename_upload']# check if the file has been uploadedif fileitem.filename_upload: # strip the leading path from the file name fn = os.path.basename(fileitem.filename_upload) # open read and write the file into the server open(fn, 'wb').write(fileitem.file.read())