Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jun 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Why is file array is not being appended to the FormData object when using Firefox?

    The following code is not working in Firefox 21 even though it corresponds to Mozilla docs on how to implement FormData in ajax. The code DOES work in both Chrome and Opera.

    Code:
    var data = new FormData(document.getElementById("uploadform"));  
    $.each($('#file')[0].files, function(i, file) {
    data.append('file-'+i, file, this.name);                    
    });
    The $.each loop is where it's bogging down because I put an alert in there which popped up in Chrome and Opera, but not in firefox.

    Here's the apache php error (occurring only when the file upload is attempted with firefox):

    Code:
    [Wed Jun 05 01:48:44 2013] [error] [client ::1] PHP Notice: Undefined index: 
    file-0 in /home/Joe/blah.com/blah.php/ on line 7, referer: http://localhost/

  • #2
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,346
    Thanks
    11
    Thanked 589 Times in 570 Posts
    Code:
    data.append('file-'+i, file, file.name);
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%

  • #3
    New to the CF scene
    Join Date
    Jun 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I tried your suggestion, however, it gives the exact same result as my code. The code works in chrome, and works in opera (meaning: a file is uploaded). It doesn't work in firefox and gives the same server error that I showed in the first post.

  • #4
    New to the CF scene
    Join Date
    Jun 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    same results with this code too:
    Code:
    var data = new FormData();  
    $.each($('#file')[0].files, function(i, file) {
    data.append('file-'+i, file);                    
    });


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •