We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

file upload + jquery ajax + phalcon - ASAP!

Hello,

I am trying to upload a file with jquery's -> $.ajax(); <- method The problem is that it works using plain PHP, but I am not getting the actual values if using Phalcon. Here's some sample code:

.. formData = new FormData($(this)[0]); $.ajax({ url: "/upload", type: 'POST', data: formData, async: false, cache: false, contentType: false, processData: false, success: function (data) { console.log(data); } });

phalcon see's that the request is been made via POST and AJAX but it's not getting the actual submited information. If this is supported by Phalcon? How the serverside code should look like?!

Thank you!

Hi, could you post relevant php and phalcon code somewhere so that we could take a look?

you cannot use phalcon\http\request\file (if you are using) for ajax/xhr file uploads, you have to get data from POST.



4.0k
Accepted
answer

Yes I know. I fixed it.

It was a problem with jquery and still is. I had it working with a pure javascript ajax request. Thank you!