Highlighted

Does input type="file" exist in the submitted form scope if left blank?

LEGEND ,
Jul 07, 2020

Copy link to clipboard

Copied

Hello, all,

 

I'm in the middle of troubleshooting an issue with server-side form validation, and am now curious.

 

If a form contains <input type="file" name="foo" /> but no file is selected when the form is submit, does the form element "foo" exist?  I mean, I know that if no checkboxes are checked, that element doesn't exist on form submit.  Do file inputs do the same?

 

V/r,

 

^ _ ^

Yes the form field for "foo" will be there but an empty string.

 

TOPICS
Advanced techniques, Asynchronous, Builder, cfchart, Cffiddle, Connector, Database access, Documentation, Event gateways, Flash integration, Getting started, Monitoring, Reporting, Security, Server administration

Views

55

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Does input type="file" exist in the submitted form scope if left blank?

LEGEND ,
Jul 07, 2020

Copy link to clipboard

Copied

Hello, all,

 

I'm in the middle of troubleshooting an issue with server-side form validation, and am now curious.

 

If a form contains <input type="file" name="foo" /> but no file is selected when the form is submit, does the form element "foo" exist?  I mean, I know that if no checkboxes are checked, that element doesn't exist on form submit.  Do file inputs do the same?

 

V/r,

 

^ _ ^

Yes the form field for "foo" will be there but an empty string.

 

TOPICS
Advanced techniques, Asynchronous, Builder, cfchart, Cffiddle, Connector, Database access, Documentation, Event gateways, Flash integration, Getting started, Monitoring, Reporting, Security, Server administration

Views

56

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jul 07, 2020 0
Explorer ,
Jul 07, 2020

Copy link to clipboard

Copied

I believe the form field will be there but the value will be empty.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 07, 2020 0
Participant ,
Jul 07, 2020

Copy link to clipboard

Copied

Yes the form field for "foo" will be there but an empty string.

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 07, 2020 1
LEGEND ,
Jul 07, 2020

Copy link to clipboard

Copied

Thank you, BeRadB and John.  I kind of suspected, but wasn't sure, and a Google search didn't help.

 

V/r,

 

^ _ ^ 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 07, 2020 1
BKBK LATEST
Adobe Community Professional ,
Jul 10, 2020

Copy link to clipboard

Copied

Hi WolfShade,

The following point is perhaps just a bit of craziness, but I shall put it out there. The file-upload form, together with content-type, is:

 

<form enctype="multipart/form-data">

<input type="file" name="foo" />

</form>

 

That is, the content-type is binary. Which gets me thinking that, when you submit the form without selecting a file, the form field exists, and has value null (clients then interpret the null as "").

 

This just might be relevant to a server whose validation code or response-header expects binary input. 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 10, 2020 1