如何防止 AsyncFileUpload 在回发时再次发送文件?

发布于 2024-09-09 02:48:19 字数 1514 浏览 8 评论 0原文

我正在开发一个管理摄影比赛的应用程序。在该应用程序中,我对用户选择的照片使用 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 技术交流群。

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

发布评论

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

评论(2

绿光 2024-09-16 02:48:19

AsyncFileUpload 实际上并不是这样工作的。仅当您在 OnUploadedComplete 事件中使用文件数据时,它才真正起作用。

我只是硬着头皮使用 SWFUpload 之类的东西,或者只使用本机 FileUpload 控件。

The AsyncFileUpload doesn't really work like this. It only really works when you use the filedata in the OnUploadedComplete event.

I'd just bite the bullet and use something like SWFUpload or just use a native FileUpload control.

暖伴 2024-09-16 02:48:19
private bool _justDeleted = false;

void AsyncFileUpload1_UploadedComplete(object sender, AsyncFileUploadEventArgs e)
{
    if (_justDeleted) return;

protected void btnDeleteLogo_Click(object sender, EventArgs e)
{
    _justDeleted = true;
private bool _justDeleted = false;

void AsyncFileUpload1_UploadedComplete(object sender, AsyncFileUploadEventArgs e)
{
    if (_justDeleted) return;

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