如何防止 AsyncFileUpload 在回发时再次发送文件?
我正在开发一个管理摄影比赛的应用程序。在该应用程序中,我对用户选择的照片使用 AsyncFileUpload 控件。服务器端 UploadedComplete 执行基本验证,并根据需要缩放/剪辑图像。
问题是,当我单击页面上的提交按钮时,AsyncFileUpload 的内容会与其他用户提交的数据一起发送,因此用户需要等待两倍的时间才能从服务器获得响应(我是照片大小在 3 到 7 Mb 之间,上传需要一两分钟)。
我的表单看起来像这样:
<%-- ... snip - all other fields ... -->
<div style="margin-top: 20px; margin-bottom: 5px;">
<span class="texteB"><b>Upload a photo</b></span><br />
Browse your computer to find a photo.</div>
<div>
<asp:AsyncFileUpload onclientuploaderror="UploadError" persistfile="true" onuploadedcomplete="fuPhoto_UploadedComplete"
completebackcolor="#52ad0b" onclientuploadstarted="UploadStarted" id="fuPhoto"
throbberid="throbber" runat="server" />
</div>
<div runat="server" id="throbber" style="display: none; margin: 8px 0 15px 0">
<div style="float: left; width: 48px;">
<img src="images/throbber.gif" /></div>
<span class="texteV_14pt"><b>Please wait while
<br />
your photo is uploaded...</b></span>
</div>
<div style="margin-top: 20px; margin-bottom: 20px;">
Please double-check your informations and press Send when ready.</div>
<div>
<asp:ImageButton onclick="btnSubmit_Click" ImageUrl="images/bt_envoyer_demande.gif"
runat="server" id="btnSubmit" />
</div>
文档中是否有我遗漏的内容?我一整天都在做这件事,但没有取得多大成功。
提前致谢!
I am developing an application that manages a photo contest. In that application, I use an AsyncFileUpload control for the user selected photo. The server-side UploadedComplete does basic validation, and scales/clip the image as necessary.
The problem is, when i click on the submit button on the page, the content of the AsyncFileUpload gets sent with the other user-submitted data, so the user gets to wait twice as long to get a response from the server (I'm expecting photos that are between 3 and 7 Mb big, which takes a minute or two to upload).
My form looks like that:
<%-- ... snip - all other fields ... -->
<div style="margin-top: 20px; margin-bottom: 5px;">
<span class="texteB"><b>Upload a photo</b></span><br />
Browse your computer to find a photo.</div>
<div>
<asp:AsyncFileUpload onclientuploaderror="UploadError" persistfile="true" onuploadedcomplete="fuPhoto_UploadedComplete"
completebackcolor="#52ad0b" onclientuploadstarted="UploadStarted" id="fuPhoto"
throbberid="throbber" runat="server" />
</div>
<div runat="server" id="throbber" style="display: none; margin: 8px 0 15px 0">
<div style="float: left; width: 48px;">
<img src="images/throbber.gif" /></div>
<span class="texteV_14pt"><b>Please wait while
<br />
your photo is uploaded...</b></span>
</div>
<div style="margin-top: 20px; margin-bottom: 20px;">
Please double-check your informations and press Send when ready.</div>
<div>
<asp:ImageButton onclick="btnSubmit_Click" ImageUrl="images/bt_envoyer_demande.gif"
runat="server" id="btnSubmit" />
</div>
Is there something I missed out in the documentation? I've been working on this all day without much success.
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
AsyncFileUpload
实际上并不是这样工作的。仅当您在OnUploadedComplete
事件中使用文件数据时,它才真正起作用。我只是硬着头皮使用 SWFUpload 之类的东西,或者只使用本机
FileUpload
控件。The
AsyncFileUpload
doesn't really work like this. It only really works when you use the filedata in theOnUploadedComplete
event.I'd just bite the bullet and use something like SWFUpload or just use a native
FileUpload
control.