O'Reilly logo

PHP 5 Power Programming by Derick Rethans, Stig Sæther Bakken, Andi Gutmans

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

5.8. File Uploads

We haven't yet covered one type of input-uploading files. You can use the file upload feature of PHP to upload images or related materials, for example. Because the browser needs to do a little bit more than just send a POST with the relevant data, you need to use a specially crafted form for file uploads. Here is an example of such a special form:

<form enctype="multipart/form-data" action="handle_img.php" method="post">
     <input type="hidden" name="MAX_FILE_SIZE" value="16000" />
     Send this file: <input name="book_image" type="file" /><br />
     <input type="submit" value="Upload" />
</form>

The differences between file upload forms and normal forms are bold in the code listing. First, an enctype attribute, included in the form ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required