使用 URLLoader AS3 上传图像进度

发布于 2024-08-06 01:37:28 字数 878 浏览 4 评论 0原文

我正在 Flash 中开发图像上传器。我使用 FileReference.browse 浏览图像,然后将该图像的大小调整为 1000 x 1000 px(如果图像很大),然后上传到服务器。我想显示图像上传进度的进度条。

我正在使用 URLLoader 发送调整大小图像的二进制数据,但 URLLoader 上的 ProgressEvent 无法按预期工作方式工作。仅在图像上传完成后才会触发,而不显示中间进度。 FileReference 上的 ProgressEvent 可以完美地显示中间图像上传进度。

有没有办法使用 URLLoader 显示上传进度?或者

我们可以使用 FileReference 加载修改后的图像,然后调用 FileReference.upload,这样就可以显示实际的进度条。


更新 1
但我的问题是,我在使用 FileReference.browse 后调整浏览图像的大小,并且我想上传调整大小的图像,而不是浏览后 FileReference 对象中的原始图片。在这种情况下如何使用 Filereference.upload ? Filereference.upload 将上传原始图像而不是调整大小的图像。任何想法,如何将调整大小的图像放入 Filereference 对象,然后使用 FileReference.upload。


更新 2
无法在虚拟 FileReference 中设置数据,数据是只读属性。


更新 3
但这有同样的问题,即不显示图像上传进度,来自上面的链接:

“不幸的是,获取进度事件时出现问题。我们无法在向服务器发送数据期间显示任何进度,因为闪存不支持它”

我正在寻找上述问题的解决方案。 URLLoader 可以很好地发布图像数据。

I am developing image uploader in Flash. I use FileReference.browse to browse image then resize this image to 1000 x 1000 px, if the image is very big and then upload to server. I want to show progressbar for the image upload progress.

I am usinng URLLoader to send binary data of the resized images, but ProgressEvent on URLLoader doesn't work the way it is supposed to work. It is fired only after the image is completed uploaded instead of showing intermediate progress. ProgressEvent on FileReference works perfectly to show intermediate image upload progress.

Is there a way to display upload progress using URLLoader? or

Can we use FileReference to load modified image and then call FileReference.upload, that way it will be possible to show actual progress bar.


Update 1 :
But my problem is that I am resizing the browsed image after using FileReference.browse, and I want to upload resized images, not the original picture in FileReference object after browse. How do I use Filereference.upload in this case? Filereference.upload will upload original image not the resized one. Any idea, how to put the resized image into Filereference object and then use FileReference.upload.


Update 2 :
Not able to set data in dummy FileReference, data is read-only property.


Update 3 :
But this has same problem of not showing image upload progress, from the above link:

"Unfortunately there is a problem getting progress event. We cant show any progress during sending data to server because flash doesn't support it"

I am exactly looking for a solution for the above issue. URLLoader works fine to post the image data.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

苦行僧 2024-08-13 01:37:28

URLLoader 的设置方式是在加载完成之前无法接收进度事件,如所述 此处 在文档中。您也许可以使用 URLStream< /code>而不是按照您的意愿获取进度事件?我不确定 URLStream 的进度事件是否仅在下载服务器响应时触发,或者是否会在完整事务(上传和下载)时触发,文档似乎没有准确指定。

URLLoader is setup in such a way that it CANNOT receive progress events until the load is complete, as noted HERE in the docs. You might be able to use URLStream instead to get the progress event as you desire perhaps? I'm not sure if the progress events for URLStream only fire for download of the server's reponse, or if they will fire for the full transaction (upload & download), the docs don't seem to specify precisely.

﹂绝世的画 2024-08-13 01:37:28

使用 FileReference.upload,这就是该方法的具体用途,您将拥有进度指示器。

Use FileReference.upload, that's specifically what that method is for, and you will have your progress indicator.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文