Example #1
0
 def POST(self):
     x = web.input(myfile={}, overwrite=0)
     filename = '_'.join(x['myfile'].filename.lstrip('/').split())#Replace space with underscore
     path = os.path.join('static', x['fileType'].lstrip('/'), x['fileIssue'].lstrip('/'), filename) #Path is a directory where we save particular file. 
     filedata = x['myfile'].value
     
     if not int(x.overwrite) and os.path.isfile(path):
         msg = "File with this name already exists. Check overwrite and try again"
         return render.upload(msg, False)
     else:
         f = open(path, 'w')
         f.write(filedata)
         f.close()
         msg = "File is saved."
         return render.upload(msg, True)
Example #2
0
 def GET(self):
     return  render.upload()