7

So I have a file upload site, which I develop using HTML5 chunking ability to upload multiple files. it works fine on Chrome, Firefox, IE (basicly browser with HTML5 capability) as well as Safari, but recently I test it out, Safari 6.0.5 works fine, but on Safari 6.1, If I upload multiple files, some files are 0 bytes. I'm not sure what happened.

When I tested, I upload about 70 files totalling 200MB, and each file is between 5-8MBish.. so there's no chunking happenening.. but when I check on the server, most file are 0 bytes (like it never get uploaded) except a few files (probably 3-5 files)

Is there any difference between Safari 6.0.5 and below, with Safari 6.1?

My code is basicly in a nutshell: Javascript will chunk each file if it's bigger than 10MB/file, if not it will just upload as is. then PHP will handle the upload (standard file upload style move_uploaded_file()).

function uploadFile(file_blob_chunk, file_name, file_part, total_file_chunk, file_id) {
    //create a progress bar based on file id (check if it's the 0 part, otherwise there will be multiple bar for same file)
    if(file_part == 0) {
        progressBar(file_id);
    }

    //ajax call for creating multipart data form
    fd = new FormData();    
    fd.append("file_for_upload", file_blob_chunk);
    fd.append("file_id", file_id);
    fd.append("file_name", file_name);
    fd.append("file_part", file_part);

    xhr = new XMLHttpRequest();
    xhr.fid = file_id;
    xhr.fid_name = file_name;
    xhr.fid_part = file_part;
    xhr.fid_total_chunk = total_file_chunk; 

    xhr.upload.fid = file_id;
    xhr.upload.fid_part = file_part;
    xhr.upload.fid_total_chunk = total_file_chunk;
    xhr.open("POST", "datas/upload/" + file_name + '/' + file_part, true);

    xhr.send(fd);

code wise it's something like that...

any idea what's wrong with safari 6.1?

I check the tmp folder, the tmp file during upload is 0 bytes..

NOTE: Safari 6.1+, If web inspector on, every file is uploaded correctly, if it's off, out of 10 files, only 3 got uploaded the rest is 0 bytes. what cause this difference?

Harts
  • 4,023
  • 9
  • 54
  • 93
  • 1
    This may or may not help, but it seems to work in Safari 7.0. I believe this is probably a bug with safari 6.1 as I've seen multiple report the same issue in 6.1. – Telshin Dec 17 '13 at 17:34
  • @Telshin it still happen on Safari 7 – Harts Dec 19 '13 at 02:08
  • How call you the function `uploadFile()`? – R3tep Jan 24 '14 at 20:37
  • What is the size of files?? – Rohit Choudhary Jan 29 '14 at 10:50
  • @R3tep The way I call the function upload File just standard. while(start < file_blob.size) { slice = file_blob.webkitSlice || file_blob.mozSlice || file_blob.slice; file_blob_chunk = slice.call(file_blob, start, end); //call the upload function to upload the file through http uploadFile(file_blob_chunk, file_blob_name, file_part, total_file_chunk, file_id); file_part++; total_chunk_all_files++; start = end; end = start + BYTES_PER_CHUNK; } – Harts Jan 29 '14 at 18:26
  • @RohitKumarChoudhary around 3-5 MB about 10 files... – Harts Jan 29 '14 at 18:27

1 Answers1

1

There are a lot of threads discussing the same problem:

file input size issue in safari for multiple file selection

https://github.com/moxiecode/plupload/issues/363

Any workarounds for the Safari HTML5 multiple file upload bug?

And the only workaround for this problem is to disable multiple upload for Safari.

Community
  • 1
  • 1
Oleg
  • 7,070
  • 4
  • 47
  • 49
  • this is not quite the same.. because most of the questions is 2 years old.. which is still the old Safari version.. and in my case Those Safari is working. Only starting from Safari 6.1 then it's not working in my case. only after I updated Safari from 6.0.5 to higher the problem occured – Harts Jan 25 '14 at 02:45