所需文件上传进度条

发布于 2025-01-04 16:02:11 字数 1783 浏览 2 评论 0原文

我需要在使用嵌入式 Microchip TCP/IP 堆栈 Pic32 板的客户端的网页界面上显示上传进度指示器。在网页中,我有一个上传文件页面,让客户端浏览并选择适当的 .hex 或 .wav 文件上传到板内存,从而最终能够引导该文件。我的问题是,当文件上传时,客户端不知道文件的进度,可能会从页面导航,从而取消下载。我需要一个指示器来显示上传进度,以便让客户了解情况。请记住,我有 5 个上传框,用于需要上传的不同实例。我一次只允许上传 1 个。

这是 html 部分的代码:

    <table width="900" border="0" cellpadding="1" class="uploadTable">
      <tr>
        <td width="420" rowspan="2"><form action="fileupload.html" method="post"   enctype="multipart/form-data">
          <div class="uploadBox"> 
            <p><b>Update Primary System Firmware</b></p>
            <p>File: 
              <input type="file" name="firmwaremain" size="30" />
              &nbsp;
              <input type="submit" value="Upload" />
            </p>
          </div>
        </form></td>
        <td width="252" height="23"><div align="center"><strong>Current File Name:  </strong></div></td>
        <td width="104"><div align="center"><strong>Current File Size:</strong></div> </td>
        <td width="104"><div align="center"><strong>File Upload Date:</strong></div></td>
      </tr>
      <tr>
        <td height="40"><div align="center">~curFirmName~</div></td>
        <td width="104"><div align="center">~curFirmSize~</div></td>
        <td width="104"><div align="center">~curFirmDate~</div></td>
        </tr>
    </table>

我有 Microchip customHTTPApp.c 代码可用,但在这里发布太麻烦了。

如果需要的话我可以发电子邮件,或者聊天。我没有发布图片的代表,而且我的网络界面站点位于独立板上,因此没有链接。

预先感谢您的帮助!

-乔什

I need to display an upload progress indicator on a webpage interface for a client using an embedded Microchip TCP/IP stack Pic32 board. In the webpage, I have an upload file page that lets the client browse and select the appropriate .hex or .wav file to upload to the board memory, and thus be able to eventually bootstrap that file. My problem is that when the file is uploading, the client is unaware of the progress the file is making, and might navigate from the page, and thus cancel download. I need an indicator to show the progress of the upload in order to keep the client informed. Keep in mind I have 5 upload boxes for the different instances needing to be uploaded. I only allow 1 upload at a time.

here is the code for html section:

    <table width="900" border="0" cellpadding="1" class="uploadTable">
      <tr>
        <td width="420" rowspan="2"><form action="fileupload.html" method="post"   enctype="multipart/form-data">
          <div class="uploadBox"> 
            <p><b>Update Primary System Firmware</b></p>
            <p>File: 
              <input type="file" name="firmwaremain" size="30" />
               
              <input type="submit" value="Upload" />
            </p>
          </div>
        </form></td>
        <td width="252" height="23"><div align="center"><strong>Current File Name:  </strong></div></td>
        <td width="104"><div align="center"><strong>Current File Size:</strong></div> </td>
        <td width="104"><div align="center"><strong>File Upload Date:</strong></div></td>
      </tr>
      <tr>
        <td height="40"><div align="center">~curFirmName~</div></td>
        <td width="104"><div align="center">~curFirmSize~</div></td>
        <td width="104"><div align="center">~curFirmDate~</div></td>
        </tr>
    </table>

I have the Microchip customHTTPApp.c code available, but it is too cumbersome to post here.

I can email if needed, or chat. I don't have the rep to post pictures, and my web interface site is in a standalone board, so no links.

Thank you in advance for the help!

-Josh

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

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

发布评论

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

评论(1

川水往事 2025-01-11 16:02:11

基本概要/想法:

  • 使用 JavaScript 超时每 N 秒轮询一次 URL:setTimeout(1000*N), "getProgress()");。这是从 onchange 为您的 type="file" input 标记调用的。
  • 您的 JS getProgress 函数向 URL 发出 Ajax 请求:http//localhost/uploadProgress< /code>
  • 你的 JS getProgress 函数也会再次调用 setTimeout 本身(相同的代码)如果
    文件尚未上传完成。
  • 您的进度 URL 返回当前上传的文件
    进度百分比(也许是字节?)作为 JSON 字符串:{progress:"50"}
  • 有一个 N 像素宽度的 DIV id="progress-complete"
    宽度等于百分比值的嵌套 DIV id="progress"
    由您的 Ajax 调用返回

如果有帮助的话,请告诉我我是否可以对此进行扩展。我只是在您需要从某个地方开始的情况下发布此内容。

A basic outline/idea:

  • Use a JavaScript timeout to poll a URL every N seconds: setTimeout(1000*N), "getProgress()");. This is called from onchange for your type="file" input tag
  • Your JS getProgress function makes an Ajax request to a URL: http//localhost/uploadProgress
  • Your JS getProgress function also calls setTimeout again on itself (same code) if
    the file is not finished uploading.
  • Your progress URL returns the currently uploading file
    progress in percentage (bytes perhaps?) as a JSON string: {progress:"50"}
  • Have a DIV of N pixels width id="progress-complete" and a
    nested DIV id="progress" with width equal to the percentage value
    returned by your Ajax call

Let me know if I can expand on that if it's helpful. I'm just posting this in the case you need somewhere to get started.

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