LPology / Simple-Ajax-Uploader

Javascript file upload plugin with progress bar support. Works in all major browsers, including IE7+, Chrome, Firefox, Safari, and Opera. No dependencies - use it with or without jQuery.
995 stars 268 forks source link

unable to upload image on php backend, no $_FILES['uploadfile'] data #112

Closed saqueib closed 9 years ago

saqueib commented 9 years ago

I am trying to use your Simple Ajax Upload but its not working, Its sending file but i am not able to get the file in $_FILES global. It seem it is sending file but without a field name, post url look like this

 http://example.com/account/avatar?uploadfile=CorporateHeadshot-41.jpg

Here is my init code

var uploader = new ss.SimpleUpload({
    customHeaders: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')},
    button: btn,
    url: '/account/avatar',
    name: 'uploadfile',
    allowedExtensions: ['jpg', 'jpeg', 'png', 'gif'],
    maxSize: 1024, // kilobytes
    hoverClass: 'hover',
    focusClass: 'focus',
    responseType: 'json',
    startXHR: function() {
        progressOuter.style.display = 'block'; // make progress bar visible
        this.setProgressBar( progressBar );
    },
    ....

Please help, how I can handle the upload at php backend, I am using Firefox 39.0

ckarea commented 9 years ago

I am having the same issue, i can get the file name by $filename = $_GET['uploadfile'];

but im not getting the $_FILES['uploadfile'] as well

ckarea commented 9 years ago

the way to fix this is to set multipart: true, and the $_FILES works fine afterward