7.8. File Uploads

A file upload is a special case of getting form input. Half of the task is putting together the correct HTML. File uploads are specified in RFC 1867. They are supported by Netscape Navigator 2 and above as well as by Internet Explorer 4 and above. Placing an input tag inside an HTML form with the type attribute set to file causes a text box and a button for browsing the local filesystem to appear on the Web page. Browsers that do not support uploads will likely render this as a text box, so it's best to present uploading forms only to capable browsers. The forms must use the post method to allow for uploads, and they must also contain the enctype attribute with a value of multipart/form-data. A hidden form variable, MAX_FILE_SIZE ...

Get Core PHP Programming, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.