为什么Javascript通过浏览器上传块大小? [英] Why Javascript upload chunk sizes change by browser?

查看:145
本文介绍了为什么Javascript通过浏览器上传块大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过JavaScript代码上传文件到服务器。我注意到不同的浏览器正在发送不同大小的字节。正如你在下面的图片中看到的那样,Internet Explorer发送的是小字节,但是Chrome和Firefox发送更大的字节。


  1. XMLHttpRequest的。我可以为所有浏览器设置标准的
    上传字节吗?因为不同大小的流量在某些浏览器上给出
    错误。 Http error is 404.13。
  2. 我将web.config文件配置为< requestLimits maxAllowedContentLength =1073741824> (1GB)当我用Firefox和Chrome上传一个大文件(500 Mb)时,服务器发出system.OutOfMemoryException异常。 Internet Explorer工作正常。

Firefox



Internet Explorer





Chrome stack.imgur.com/Tcw6F.pngalt =在这里输入图片描述>

解决方案

我不知道为什么这是不同的,但是你可以改变你的行为基于浏览器(而不是像你问的问题标准化)。



请参阅moo uploader中的代码为一个例子。



发件人: https://github.com/juanparati/MooUpload/blob/master/Source/MooUpload.js

  //获取sli ce方法
if(file.mozSlice)//基于Mozilla的
chunk = file.mozSlice(开始,总计)
else if(file.webkitSlice)// Chrome,Safari,Konqueror和webkit基于
chunk = file.webkitSlice(start,total);
else // Opera和其他标准浏览器
chunk = file.slice(开始,总计)


I am uploading files by javascript code to server. I noticed that different browsers are sending bytes of different sizes. As you can see in the following pictures, Internet Explorer is sending small bytes but Chrome and Firefox send bigger bytes.

  1. I am uploading files with XMLHttpRequest. Can I set standard upload bytes for all browsers? Because different size flow is giving errors on some browsers. Http error is 404.13.
  2. I configured web.config file as <requestLimits maxAllowedContentLength="1073741824">(1GB) but when I upload a big file(500 Mb) with Firefox and Chrome, the server is giving system.OutOfMemoryException. Internet Explorer is working fine.

Firefox

Internet Explorer

Chrome

解决方案

I don't know why it's different, but you can alter your behavior based on the browser (as opposed to standardizing as you asked in the question).

Refer to the code in the moo uploader as an example.

From: https://github.com/juanparati/MooUpload/blob/master/Source/MooUpload.js

    // Get slice method
    if (file.mozSlice)          // Mozilla based
      chunk = file.mozSlice(start, total)
    else if (file.webkitSlice)  // Chrome, Safari, Konqueror and webkit based
      chunk = file.webkitSlice(start, total);
    else                        // Opera and other standards browsers
      chunk = file.slice(start, total)

这篇关于为什么Javascript通过浏览器上传块大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆