Where are my $ _FILES? Ajax uploading

I created an image upload form and processed Prototype / PHP.

$('image_upload').observe('submit', function() {

     var params = $H();
     params.set('name', $('image_title').value);
     params.set('from', $('from_who').value);
     params.set('upload_file', $('upload_file').value);

     new Ajax.Request('/files/upload_process.php', {
      method:'post',
      parameters: params,

      onSuccess: function(r) {
       $('uploadbox').update('<img src="/images/interface/thankyou.png" />');


      }

     })



    });

The form itself sends data to the server, but when you try to output, print_r($_FILES['upload_file']);nothing appears, even an empty array.

If I deduce print_r($_POST), the parameters are sent correctly, but only the image file name.

So it seems that the files themselves are not being sent. How can I handle this? thanks rich

+5
source share
2 answers

I do not think that you can send files via ajax for security reasons. You will need to submit the form in an iframe and process it from there.

+6
source

XHR .
IFRAME, flash/Java, .

+3

All Articles