• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

LEGEND ,
Jul 07, 2020 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,

 

^ _ ^

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

Views

232

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
community guidelines

correct answers 2 Correct answers

Explorer , Jul 07, 2020 Jul 07, 2020

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

Votes

Translate

Translate
Participant , Jul 07, 2020 Jul 07, 2020

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

 

Votes

Translate

Translate
Explorer ,
Jul 07, 2020 Jul 07, 2020

Copy link to clipboard

Copied

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

Iambradb.com Adobe ColdFusion Specialist.

Votes

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
community guidelines
Participant ,
Jul 07, 2020 Jul 07, 2020

Copy link to clipboard

Copied

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

 

Votes

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
community guidelines
LEGEND ,
Jul 07, 2020 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,

 

^ _ ^ 

Votes

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
community guidelines
Community Expert ,
Jul 10, 2020 Jul 10, 2020

Copy link to clipboard

Copied

LATEST

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. 

Votes

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
community guidelines
Resources
Documentation