File Upload with PHP

Many people are disappointed to find that there is no visual upload file functionality in GoLive 6 or Dreamweaver MX. You'll just have to get your hands dirty and hand code the php page for this yourself. Follow these steps to create the html page with form and the php page that processes the upload.

For this tutorial we'll use GoLive 6, but you can adapt it just as easily for Dreamweaver MX. You'll need a web server set up with PHP enabled. If you have Mac OSX, read my tutorial for setting up your computer for php/mySQL. If you need a good and inexpensive PHP/mySQL host with great technical support, take a look at GoLive Host.

Create a Form

First create a simple form so that the user can browse his HD for the file to upload. Mine is a form for employees to upload pictures to the server of cats up for adoption at an imaginary cat rescue center.

Select the forms tab on the objects panel so that you can readily access various form objects. Drag a form to the page.

Form Tag Settings

In the Inspector, set the method to POST, encode to multipart/form-data, action to the name you will give the php page that will process the file (such as processFile.php) and give your form a name.

File Browser Settings

Drag the "file browser" form object to the page. Give it name (such as sendCat) as this will be used to identify the file the user sends. You can set visible to any character length you like. I made mine 25.

Submit Button settings

Drag a submit button to the page. In the Inspector, you can name it submit and give it a meaningful label. Mine says "Send Picture"

Hidden field settings

Drag a hidden form object to the page. Name it MAX_FILE_SIZE and set the value to the largest file size you will permit a user to send. The size is calculated in bytes. I am setting mine for small jpg's of 5,000 bytes. This hidden input field must be above the file input field!

File Browser Form

The final output will look something like this:

Here is what my code looks like:

<form action="processfile.php" method="post" name="petpic" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="5000" border="0">
<input type="file" name="sendCat" size="25" border="0">
<p><input type="submit" name="submit" value="Send Picture" border="0"></p>
</form>

Remember the following factors:

Now let's create the php page to process the upload -->