前台代码:
<form id="upload" action="/designer/uploadandcut" method="post" enctype="multipart/form-data"> <input type="file" name="headimage" id="headimage" style= "display:none"/></form> 后台代码:
#上传和剪裁
@expose()
def uploadandcut(self,username,headimage):
print 'run'
permanent_file = open(os.getcwd()+"\\designerpage\\public\\"+username+"\\headimage\\headimage.png",'wb')
print permanent_file
shutil.copyfileobj(headimage.file,permanent_file)
headimage.file.close()
permanent_file.close()
redirect("/designer/designerMyIndex")