Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
[SOLVED] XMLHttpRequest for Upload file
  • Hi every body,

    I want to doing a file uploader with a XMLHttpRequest, but when I want to process the upload in fuel, I have this error :
    "Fuel\Upload\NoFilesException [ Error ]:
    No uploaded files were found. Did you specify "enctype" in your <form> tag?"
    PHP return this fatal error on exec the \Upload::process method.

    In my opinion, my HTTP request is correct :
    I have the content-type header is definied on "multipart/form-data; boundary=---------------------------211993223319997"
    and the datas of the header contain my file datas preceded by
    "-----------------------------211993223319997
    Content-Disposition: form-data; name="file"; filename="720p_HD_Video.mp4"
    Content-Type: video/mp4".

    My javascript code :
    request = new XMLHttpRequest();
    request.open('POST', BASE_URL + 'admin/videos/upload.json');
    var form = new FormData(document.getElementById('upload_form'));
    request.send(form);

    My php code :
    public function post_upload() {
            $uploadConfig = array(
                'ext_whitelist' => array('asf', 'asx', 'avi', 'divx', 'dv', 'dvx', 'flv', 'm4v', 'mov', 'mp4', 'mpeg', 'mpg', 'qt', 'wmv', '3g2', '3gp', '3ivx', '3vx'), // Get from DMC documentation
                'path' => DOCROOT . 'medias' . DS . 'videos' . DS,
            );
            /* Save the upload */
            \Upload::process($uploadConfig);
            [...]
    }
  • You get that error if $_FILES is empty. So something isn't going right with that POST...
  • I have found my problem : it was just the upload_max_filesize and the post_max_size variables that defined on a too low value ^^

    Thank you anyway Harro Verton

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion