上传照片
我的问题是关于将照片上传到网络服务器。
我最近在 Facebook 上上传照片时观察到,它可以上传(默认情况下确实如此)上传比我们要求的更小的照片。
现在,我可以考虑上传全尺寸照片并在到达服务器时进行压缩。
但是 facebook 如何在上传时调整图片大小。是否有任何请求标头(我认为没有)要求浏览器上传特定尺寸的图像并操作文件中的 exif/jpeg 数据。
如果没有,某些插件/Flash/Javascript 必须读取来自我们系统的文件/图像。 网络标准真的允许从用户系统读取文件吗?
请指教。
问候,
玛雅克
My question is regarding uploading photographs to a webserver.
I recently observed while uploading a photograph on facebook that it can upload (and by default it does) upload smaller photographs than what we request.
Now, I can think of uploading a full size photograph and compress when it reaches the server.
But how could facebook resize the picture while uploading.Is there any request header (I think there is not) that asks browser to upload specific size image and manipulate the exif/jpeg data in the file.
If not, some plugin/Flash/Javascript has to read the file/images from our system. Does web standard really allow file reading from the user system?
Please advise.
Regards,
Mayank
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在上传并保存到目标目录之前,网站/网络服务器无法对图像执行任何操作。它必须接收全尺寸图像,然后将其重新定位到所需尺寸[生成缩略图等]。没有您描述的请求标头。
Web 标准不允许从用户硬盘读取文件。他们允许的事情是从硬盘中选择文件然后发送到服务器 - 主动权在客户端,而不是服务器。
您还有什么想了解的吗?
更新
请参阅:Flash 上传图像调整大小客户端
正如我所说 - 没有外部机制我们什么也做不了。但当然,如果我们考虑到 Flash、Google Gears 等,一切皆有可能。
Website / webserver cannot do anything with the image until it is uploaded and saved into target directory. It must receive fullsize image and then resite it to desired size [generate thumbnails, etc.]. There is no request header that you described.
Web standards don't allow reading files from user hard disk. The thing that they allow is to select file from hard disk and then send to server - initiative is on the client's side, not server's.
Is there anything more you would like to know?
update
See this: Flash upload image resize client side
As I said - without external mechanisms we can't do anything. But of course, if we take into account Flash, Google Gears and so on, everything is possible.
现在 HTML5 已成为可能
目前并非所有浏览器都支持它,但是 HTML5 中的某些功能可以在通过网络发送图像之前调整图像大小。
看看 hacks.mozilla.org...了解更多详情
摘自上述链接:
It is now possible with HTML5
Not all browsers accommodate it at the present however there are some features in HTML5 that will resize an image before it sends it over the wire.
Look at hacks.mozilla.org... for more details
Excerpt from the above link: