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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access