上传图片的缩略图服务器,无需上传整个图像上传图片、缩略图、图像、上传

2023-09-09 21:28:15 作者:吐个泡泡

据我所知,我问这里是不可能的,但我想我会在情况下,我失去了一些东西反正问。

As far as I know, what I ask here isn't possible, but I thought I'd ask anyway in case I'm missing something.

假设你想让用户上传JPG图像,并将这些图像缩放成更小的图标和原始图像总是被丢弃,又从来没有要求。是否有将让用户选择自己的硬盘驱动器上的单个图像的任何方式,将一般工作在最现代的浏览器,有局部变成一个缩略图,创建缩略图上传到服务器?

Suppose you want to let users upload JPG images, and these images are scaled into smaller icons and the original images are always discarded and never required again. Is there any way that would commonly work in most modern browsers that would let the user select a single image on their hard drive, have that LOCALLY turned into a thumbnail and upload the created thumbnail to a server?

在其中服务器只需要一个小的图像的情况下,这将是一种浪费都在用户的时间和资源服务器以继续上载图像整体,只有立即丢弃它。这将是更好的,只是它的规模在客户端上。

In a case where the server just needs a small image, it would be wasteful both in user time and server resources to proceed uploading the whole image, only to immediately discard it. It would be much better to just scale it on the client.

我可以想像三个选项。只是普通的HTML / Javascript中,使用Flash或使用Java。如果这是可能配备闪光灯,这似乎是最好的选择。但是阅读器flash.net.FileReference文档,似乎可以从HD是上传文件,但你可以不看你上载的文件中。在另一方面,如果启用可以访问本地文件在Flash发布选项,似乎你便无法上网,这样是行不通的。

I can imagine three options. Just plain HTML/Javascript, using Flash or using Java. If this were possible with Flash, that would seem like the best option. But reading flash.net.FileReference documentation, it seems that you can upload a file from the HD yes, but you cannot look inside the file you are uploading. On the other hand, if you enable "can access local files" in Flash publishing options, it seems that you can then no longer access the net, so that doesn't work.

使用HTML / Javascript中,有可能加载图像和显示他们<画布> ,但如果您尝试访问这些图像的像素,获得安全违规,所以似乎并没有工作。

With HTML/Javascript, it is possible to load images and display them on a <canvas>, but if you try to access the pixels of these images, you get security violations, so that doesn't seem to work.

Java的我毫不犹豫地使用,因为只有96.52%的我的用户安装了它,并在文件上传对话框在Java中我看到了实现(在Facebook的为例)都无法正常运作,(反应迟钝的接口)。虽然我不知道,如果Java是唯一允许从本地高清调整图像大小?

Java I hesitate to use, because only 96.52% of my users have it installed, and the file upload dialogs I have seen implemented in Java (at Facebook for example) have not worked well (unresponsive interface). I wonder though if Java is the only thing allowing resizing images from local HD?

推荐答案

我想,如果有一个合理可靠的和用户友好的方式来做到这一点,它会在被Facebook这样的网站已经完成。人们习惯把上传的原始图像...它总是很高兴能改善已建立的UX上,但如果你只能匹配它,你没有完全失去了。

I think if there was a reasonably reliable and user-friendly way to accomplish this, it'd be done on sites like Facebook already. People are used to having to upload the original image... it's always nice to be able to improve on an established UX, but if you can only match it, you're not exactly losing out.

JavaScript是出来了,因为JS不能直接从客户端读取任何东西;它只能指示浏览器从服务器加载$ P $对 - 定义的局部路径,或装载字节。

JavaScript is out, because JS cannot read anything directly from the client; it can only direct the browser to load a pre-defined local path, or load bytes from the server.

Flash的安全沙箱也prevents这一点,正如你所指出。

Flash's security sandbox also prevents this, as you pointed out.

Java有不同的问题 - 人们很少安装小程序,这些天,除非他们信任的网站超过了他们自己的家庭成员。这显然​​也很难建立一些可靠的和的使用,就证明了Facebook的式的公司,拥有几乎无限的资源扔问题,但还是失败。

Java has a different set of problems - people rarely install applets these days unless they trust the site more than their own family members. It's also apparently extremely difficult to build something reliable and usable, as evidenced by Facebook-esque companies which have practically unlimited resources to throw at the problem and still fail.

因此​​,简言之 - 没有,也不要太​​担心它

So, in summary - no, and don't worry too much about it.