Thursday, July 30, 2009

[jQuery] Re: Detect ajax with file uploads

If you're doing an ajax-like file upload (using jQuery) then you can add a hint in your post data, like format=ajax. Normal file uploads would not have this hint, so you can use that to choose how to handle the upload.

--
Hector
Sent from Temecula, California, United States

On Thu, Jul 30, 2009 at 11:37 AM, Grundee <grundee@gmail.com> wrote:

When the ajax form is uploading a file it uses a hidden IFRAME as the
target.
HTTP_X_REQUESTED_WITH is set when it is submitted using the
XMLHttpRequest, but files cannot be uploaded this way.

There isn't any way I know of to detect an AJAX request specifically
in this instance (being as this is technically not AJAX)
but you can check that HTTP_X_REQUESTED_WITH is not set and that the
file is uploaded in $_FILES.

No comments: