0

I am new to PHP and HTML, and have trouble understanding the enctype attribute of the form when using POST. In all examples of File Upload using PHP, it is written that I should set enctype as multipart/form-data (which, as far as I understand, is used for files). However in all these examples, the only input on the form is file input.

My question is, what if I want to have form with mixed inputs? Particularly, both text and file. Then, if I set enctype to multipart/form-data, will I still be able to access both files and text from PHP using $_FILES and $_POST?

Thank you

4

2 回答 2

1

It basically means, add the $_FILE array to the request. For more information, read this question
What does enctype='multipart/form-data' mean?

于 2012-09-06T08:34:46.660 回答
1

Use multipart/form-data.

It converts each piece of data to a part in a multi-part MIME request (and then does some specific encoding of each part). It isn't just for files, and if you are using PHP then $_POST will be populated normally.

The alternative (application/x-www-form-urlencoded) basically builds a query string. For a POST request it makes that query string the request body. This format doesn't have any provision for encoding files.

于 2012-09-06T08:36:58.730 回答