简体   繁体   中英

Form isnt submitting an input type:file like it should

I was checking with the page it was posting to: hello.aspx, and there were not files inside the Request object.

I used jQuery to move move this input INTO the form after it is assigned a file, so the first thing i dd was to double check to make sure the object was placed correctly with the correct contents. (seemingly, yes).

The form markup ends up looking exactly as follows:

<form enctype="multipart/form-data" method="POST" target="myFrame" action="hello.aspx" id="IE9Images">
    <input type="file" class="new_file" />
</form>

Now at first, i was thinking the input would need a name attribute: So i added one:

name="myFile"

still nothing in the server request. I changed method, thinking it was case sensitive:

method="post"

and still nothing.

I looked at the attributes of the input, and YES, there is actually a file associated with it: kev.png .

Is there something obvious i am missing when it comes to forms? It does actually submit everything correctly, but it doesnt recognize the input.

edit: Make sure all inputs in a form have a name so that way it is referenced on the server.

You're missing enctype="multipart/form-data" .

This is required for forms with file-inputs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM