如何获取 imageView 中图像的图像名称?
您好,我想将图像上传到 HTTP 服务器,图像上传工作正常,但每次服务器中的图像都会被新图像替换。有人可以帮我实现下面的注释行吗? 谢谢...
- (IBAction)upload{ //NSString *imagename=imageview.image; //[self uploadImage:UIImageJPEGRepresentation(imageview.image, 1.0) filename:imagename]; [self uploadImage:UIImageJPEGRepresentation(imageview.image, 1.0) filename:@"facebook.jpg"]; }
Hi i want to upload the image to HTTP server, image upload is working fine but every time the image in the server is replaced with the new image. Can some one help me to implement the commented lines below.
Thanks...
- (IBAction)upload{ //NSString *imagename=imageview.image; //[self uploadImage:UIImageJPEGRepresentation(imageview.image, 1.0) filename:imagename]; [self uploadImage:UIImageJPEGRepresentation(imageview.image, 1.0) filename:@"facebook.jpg"]; }
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要获取图像的文件名,请在文件选取期间捕获名称(但请记住,图像视图中的图像可能直接来自相机)。
如果文件上传不应覆盖服务器上已有的文件,请考虑以下方法之一:
a) 为每次上传生成唯一的文件名(最好在服务器代码中,但如果您还控制客户端) ,你也可以在那里做)。您可以使用 UUID 作为唯一的文件名。
或者
b) 将图像存储在数据库而不是文件系统中
To get the image's filename, capture the name during the file picking (but remember, maybe the image in the image view comes directly from the camera).
If the file upload should never overwrite a file already on the server, consider one of the following:
a) generate a unique filename for each upload (preferably in the server code, but if you also control the client, you can do it there too). You could use UUIDs as unique filenames.
OR
b) store the images in a database instead of the filesystem