Bug Tracker

Opened 11 years ago

Closed 10 years ago

Last modified 8 years ago

#3290 closed bug (invalid)

File Upload field results in jQuery doing a form submit, dropping page element in POST

Reported by: taylors Owned by: malsup
Priority: major Milestone: 1.3
Component: plugin Version: 1.2.3
Keywords: form upload fi Cc: malsup, taylors
Blocked by: Blocking:

Description

When submitting a form (via submit element) containing a file upload, the page element is left out of the POST request.

In jquery.form.js (v2.07), it is stated:

@desc Submit form and update page element with server response

This is violated if files are present (or options.iframe - line 244) and the fileUpload() function is called. This results in a form.submit() action on line 318, rather than submitting the page element and other options present. Please contact me for further clarification.

Change History (5)

comment:1 Changed 11 years ago by flesler

Cc: malsup taylors added
Component: coreplugin
Keywords: form upload fi added
Owner: set to malsup

comment:2 Changed 11 years ago by malsup

the page element is left out of the POST request

I don't understand what you mean by this. Can you please explain or post an example?

comment:3 Changed 11 years ago by mgedmin

Suppose you have a form like this

<form action="..." method="post" enctype="multipart/form-data">

<input type="hidden" name="extra_data" value="42" /> <input type="file" name="the_file" /> <input type="submit" name="UPLOAD" value="Upload file" />

</form>

and you make it AJAX-y by calling jQuery's ajaxForm().

Now if you press the UPLOAD button without selecting a file, the web server will see extra_data=42&the_file=&UPLOAD=Upload+file, which is correct.

If you select a file and then press UPLOAD, the web server will see extra_data and the the_file fields, but UPLOAD field will be missing from the request.

This is bad if you have multiple submit buttons and want to determine which one was pressed. It is also contrary to jQuery's documentation that taylors quoted. .

comment:4 Changed 11 years ago by malsup

This was fixed in version 2.12.

comment:5 Changed 10 years ago by dmethvin

Resolution: invalid
Status: newclosed

This is not a jQuery core bug. Please report plugin bugs to the plugin's author, or ask on the jQuery forums. jQuery UI bugs should be reported on the UI bug tracker, http://dev.jqueryui.com .

Note: See TracTickets for help on using tickets.