Team LiB
Previous Section Next Section

Understanding the Process

The process of uploading a file to a web server through an HTML form interface puzzles a lot of people. Take a moment to understand the process you'll create in the following sections.

To start and finish this process, you need the following:

The process itself goes something like this:

  1. The user accesses the HTML form and sees a text field and the Browse button in his or her web browser.

  2. The user browses his or her hard drive for the file to upload and then selects a file.

  3. The full file path and filename appear in the text field.

  4. The user clicks on the submit button.

  5. The selected file goes out, lands at the web server, and sits around in a temporary directory.

  6. The PHP script used in the form action checks that a file was sent, and then executes a copy command on the temporary file to move it to a real directory on the web server.

  7. The PHP script confirms the action for the user.

Note 

The PHP user (the user under which PHP runs, such as "nobody" or "www" or "joe") must have write permissions in the temporary directory as well as the target directory for the file. If you have difficulty with permissions, contact your system administrator.

Start by simply creating the HTML form interface in the next section.


Team LiB
Previous Section Next Section