Exemplo n.º 1
0
 def POST(self):
     try:
         i = web.input(myfile={})  # the default paramter 'file={}' is needed
     except ValueError:
         msg = "File too large"
         return admin_render.media(msg=msg)
     upload_to = u"upload"
     if "myfile" in i:  # i.myfile is a file-field object
         filepath = i.myfile.filename.replace("\\", "/")  # replace the windows-style slashes
         filepath = filepath.encode("utf-8")
         filename = filepath.split("/")[-1]
         fout = open(upload_to + "/" + filename, "wb")
         fout.write(i.myfile.file.read())
         fout.close()
     raise web.seeother("/media")
Exemplo n.º 2
0
 def GET(self):
     return admin_render.media()