Handling File Uploads
I’m going to begin this chapter by demonstrating how to accept file uploads in your forms. Like handling any HTML form using PHP, the process of uploading a file has two dimensions. First the HTML form must be displayed, with the proper code to allow for file uploads. Then upon submission of the form, the PHP script must copy the uploaded file to the proper location.
However, for this process to work, several things must be in place:
PHP must run with the proper settings.
A temporary storage directory must exist with the proper permissions.
The final storage directory must exist with the proper permissions.
With this in mind, I’ll first adjust the server to ensure that file uploads are allowed. Then I’ll create the upload ...
Get PHP and MySQL for Dynamic Web Sites: Visual Quickpro Guide, Second 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.