Commits

Anonymous committed eaf74cc

保存站外图片自定义文件名

Comments (0)

Files changed (2)

         if u  :
             self.template_value['albums'] = Album.all()
             self.template_value['u']=u
+            self.template_value['name']= u.split("/")[-1] or "aaaa"+ mime.split("/")[-1]
             return self.render("upload-web2.html")
         self.render("upload-web.html")
         
         album = self.request.get("album")
         u = self.request.get("u")
         des = self.request.get("des")
-       
+        name = self.request.get("name")
         result = urlfetch.fetch(u)
         if result.status_code == 200:
             album = Album.get_by_key_name(album)
             mime = getImageInfo(bf)[0]
             if mime.find("image") <0:
                 raise Exception(u"不是正确的图片")
-            name = u.split("/")[-1] or "aaaa"+ mime.split("/")[-1]
             img = Image.add(album,name,mime,bf,**{"description":des})
             self.redirect(album.m_url)
             

themes/admin/upload-web2.html

 	 <label for="album">选择相册</label>
     </p>
 	<p>
+		<input  name="name" type="text" style="width:200px;" maxlength="100" value="{{name}}"> <label for="name">文件名</label>
+	</p>
+	<p>
 		<input  name="u" type="text" style="width:400px;" maxlength="100" value="{{u}}">
     <p>
         <p><textarea id="des" name="des" style="width:400px"></textarea></p>