xmlhttprequest-level2

XMLHttpRequest upload progress event doesn't work in Firefox 10.0.2

て烟熏妆下的殇ゞ 提交于 2019-12-11 03:08:41
问题 I'm trying to create an ajax based upload form with progress bar. This is my code (the upload part of it): $xhr = new XMLHttpRequest(); $xhr.upload.addEventListener("progress", function(e) { if (e.lengthComputable) { $progress = (e.loaded / e.total) * 100; $('#file-progress').css('width', $progressWidth * (e.loaded / e.total)); $('#percentage').html($progress.toFixed(2) + '%'); } else { alert('Y U NO WORK?'); } } , false); $xhr.onreadystatechange = function(e){ if($xhr.readyState == 4) { //i

Is it possible to set accept-charset for new FormData (XHR2) object or workaround

◇◆丶佛笑我妖孽 提交于 2019-12-08 17:09:49
问题 Here is example code (http://jsfiddle.net/epsSZ/1/): HTML: <form enctype="multipart/form-data" action="/echo/html" method="post" name="fileinfo" accept-charset="windows-1251"> <label>Label:</label> <input type="text" name="label" size="12" maxlength="32" value="får løbende" /><br /> <input type="submit" value="Send standart"> </form> <button onclick="sendForm()">Send ajax!</button> JS: window.sendForm = function() { var oOutput = document.getElementById("output"), oData = new FormData

Accessing ArrayBuffer from PHP $_POST after xmlHTTPrequest send()

我只是一个虾纸丫 提交于 2019-12-07 13:00:17
问题 I'm following the tuitions on XMLHttpRequest 2 from : https://developer.mozilla.org/en/DOM/XMLHttpRequest/Sending_and_Receiving_Binary_Data and http://www.html5rocks.com/en/tutorials/file/xhr2/#toc-send-arraybuffer They're great tutorials for the client side, and here is a working extract from my script: var imagebuffer = new ArrayBuffer(size); // create the readonly memory buffer var imagedata= new Uint8Array(imagebuffer); // create a view to manipulate data // do some cool stuff with

JS ProgressEvent is only fired when finished

[亡魂溺海] 提交于 2019-12-04 07:41:50
I am having some problems getting my upload progress bar to work properly. According to the XMLHttpRequest Level 2 specs, I attached event listeners for loadstart and progress like this: var xhr = $.ajaxSettings.xhr(); xhr.upload.addEventListener('loadstart', function(e) {progressCallback(0);}); xhr.upload.addEventListener('progress', function (e) { progressCallback(e.loaded / e.total); }); $.ajax({ url: url, type: 'POST', processData: false, contentType: false, data: formData, xhr: function () { return xhr; } }).done(function (data) { // Finish stuff }) The file is correctly uploaded but the

xhr.upload.onprogress doesn't work

。_饼干妹妹 提交于 2019-12-04 04:57:05
Everything in the following code will work, except it will never fire the xhr.upload.onprogress event. $(function(){ var xhr; $("#submit").click(function(){ var formData = new FormData(); formData.append("myFile", document.getElementById("myFileField").files[0]); xhr = new XMLHttpRequest(); xhr.open("POST", "./test.php", true); xhr.send(formData); xhr.onreadystatechange = function(){ if(xhr.readyState === 4 && xhr.status === 200){ console.log(xhr.responseText); } } xhr.upload.onprogress = function(e) { // it will never come inside here } }); }); You should create the listeners before opening

ArrayBuffer vs Blob and XHR2

◇◆丶佛笑我妖孽 提交于 2019-12-03 08:43:38
问题 XHR2 differences states The ability to transfer ArrayBuffer, Blob, File and FormData objects. What are the differences between ArrayBuffer and Blob ? Why should I care about being able to send them over XHR2 ? (I can understand value of File and FormData) 回答1: This is an effort to replace the old method which would take a "string" and cut sections of it out. You would use an ArrayBuffer when you need a typed array because you intend to work with the data, and a blob when you just need the

iOS 6 (iPhone/iPad) Image Upload “Request Body Stream Exhausted” with NTLM/Windows Authentication

天涯浪子 提交于 2019-11-30 13:59:05
I am working on trying to get iOS 6 to use XMLHttpRequest POSTs to upload images. This works on desktop and Android web browsers, but with iOS 6 I am getting an error on the page being posted to: "Request Body Stream Exhausted". (Using iOS Simulator with the Safari Web Inspector). Here is the basic code of the page: function fileSelected() { var file = document.getElementById('fileToUpload').files[0]; if (file) { var fileSize = 0; if (file.size > 1024 * 1024) fileSize = (Math.round(file.size * 100 / (1024 * 1024)) / 100).toString() + 'MB'; else fileSize = (Math.round(file.size * 100 / 1024) /

iOS 6 (iPhone/iPad) Image Upload “Request Body Stream Exhausted” with NTLM/Windows Authentication

杀马特。学长 韩版系。学妹 提交于 2019-11-29 19:18:49
问题 I am working on trying to get iOS 6 to use XMLHttpRequest POSTs to upload images. This works on desktop and Android web browsers, but with iOS 6 I am getting an error on the page being posted to: "Request Body Stream Exhausted". (Using iOS Simulator with the Safari Web Inspector). Here is the basic code of the page: function fileSelected() { var file = document.getElementById('fileToUpload').files[0]; if (file) { var fileSize = 0; if (file.size > 1024 * 1024) fileSize = (Math.round(file.size

What is the maximum file upload size with xmlhttprequest level 2?

放肆的年华 提交于 2019-11-29 15:34:10
What is the maximum file upload size with xmlhttprequest level 2 with HTML5? Rob W The XMLHttpRequest specification does not mention any limits on the upload size. In practise, upload requests are limited by: The number of simultaneous uploads: How many concurrent AJAX (XmlHttpRequest) requests are allowed in popular browsers? The configured limit on the web server, eg. LimitRequestBody on Apache, client_max_body_size on Nginx. The limits in the server-side scripting environment, e.g. upload_max_filesize and post_max_size in PHP. Memory limits ( bugs , client-side or server-side). See also:

Uploading a file with XMLHttprequest - Missing boundary in multipart/form-data

邮差的信 提交于 2019-11-29 06:54:11
I'm uploading a file with XMLHttprequest. Here is the JS function, that uploads a file: var upload = function(file) { // Create form data var formData = new FormData(); formData.append('file', file); var xhr = new XMLHttpRequest(); // Open xhr.open('POST', this.options.action); // Set headers xhr.setRequestHeader("Cache-Control", "no-cache"); xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest"); xhr.setRequestHeader("Content-Type", "multipart/form-data"); xhr.setRequestHeader("X-File-Name", file.fileName); xhr.setRequestHeader("X-File-Size", file.fileSize); xhr.setRequestHeader("X-File