1 #Coding=utf82 ImportWeb3 4URLs = ('/','Home',5 '/upload','Upload')6 7App =web.application (URLs, Globals ())8 9 classUpload:Ten defGET (self): OneWeb.header ("Content-type","text/html; Charset=utf-8") A return """ - <form method= "POST" enctype= "Multipart/form-data" action= "" > - <input type= "file" name= "MyFile"/> the <br/> - <input type= "Submit"/> - </form> - </body>""" + defPOST (self): -x = Web.input (myfile={}) +Filedir ='./' #Change this to the directory of your want to store the file in. A if 'myfile' inchX:#To Check if the file-object is created atFilepath=x.myfile.filename.replace ('\\','/')#replaces the Windows-style slashes with Linux ones. -Filename="Thisismy.file" #Splits the and chooses the last part (the filename with extension) -Fout = open (Filedir +'/'+ filename,'W')#creates the file where the uploaded file should be stored -Fout.write (X.myfile.file.read ())#writes the uploaded file to the newly created file. -Fout.close ()#closes the file, upload complete. - RaiseWeb.seeother ('/upload') in - if __name__=="__main__": toApp.run ()