Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Chrome for IOS 6 ajax file uploading progress event doesn't work

I have a problem with xmlhttprequest file uploading progress event on Google Chrome for ios6. code already work on all desktop browsers and Safari(ios 6). also there is a problem wiht uploading mov files in google chrome (ios 6), when trying to upload I get file size = 0. Is there any solution for it ?

this is part of my code

var xhr = new XMLHttpRequest();
var eventSource = xhr.upload;

xhr.addEventListener("load", this.onUploadComplete(uploadInfo));
xhr.addEventListener("error", this.onUploadError(uploadInfo));
xhr.addEventListener("abort", this.onUploadAbort(uploadInfo));

// changing Url  for preventing ajax call caching( Android , IOS 6)
var ts = Date.now(), rquery = /\?/, rts = /([?&])_=[^&]*/,
ret = uploadUrl.replace( rts, "$1_=" + ts );
uploadUrl = ret + ( ( ret === uploadUrl ) ? ( rquery.test( uploadUrl ) ? "&" : "?" ) + "_=" + ts : "" );

xhr.open('POST', uploadUrl, true);  
eventSource.onprogress = this.onUploadProgress(uploadInfo);
xhr.setRequestHeader("Content-Type", "multipart/form-data");

xhr.setRequestHeader('X-FILE-NAME', file.name);
xhr.send(file);
like image 561
Arshak Avatar asked Oct 06 '22 15:10

Arshak


1 Answers

This is a known bug for Chrome on iOS, it doesn't support progress update. More details here: https://github.com/blueimp/jQuery-File-Upload/wiki/Browser-support

Also, I have reported the bug to the official bug tracker, you can see the latest updates here

UPDATE 2016: It has been fixed!

like image 115
wont_compile Avatar answered Oct 10 '22 04:10

wont_compile