JDT

 

FREE Downloads
Articles
Tutorials

 

Creating a Simple File Uploader Using PHP - Part 2


In this series of tutorials we will look at how to develop a simple file uploader using PHP. All of the code is freely available for download (License: GNU GPL) from this link: Download File Uploader.

In this tutorial, we will look at how to create a simple form to enable you to browse to, and then upload, a file.

Here is a simple form to enable a file to be uploaded:

<form name="form1" method="post" action="fileUpload.php" enctype="multipart/form-data" onSubmit='return checkfields();'>
<table>
<tr>
<td><p>FTP Host Server (eg abc.xyz.com):</p></td><td><p><input type="text" name="host" size="40"></p></td>
</tr>
<tr>
<td><p>Username:</p> </td><td><p><input type="text" name="username" size="40"></p></td>
</tr>
<tr>
<td><p>Password:</p></td> <td><p><input type="password" name="password" size="40"></p></td>
</tr>
<tr>
<td><p>Source File (Max. 500KB):</p></td> <td><p><input type="file" name="sourcefile" size="40">
<input type="hidden" name="MAX_FILE_SIZE" value="500000"></p></td>
</tr>
<tr>
<td><p>Target Folder (eg /home/john/public_html/uploads/):</p></td> <td><p><input type="text" name="targetfolder" size="40"></p></td>
</tr>
<tr>
<td colspan="2">
</td>
</tr>
<tr>
<td align="center" colspan="2">
<input type="submit" name="Submit" value="Upload File"></p>
</td>
</tr>
</table>
</form>

FTP Host Server - the server where you will transfer the file to.

Username - the username to access (log onto) the server.

Password - the password to access (log onto) the server.

Source File - the file to be uploaded.

Target Folder - the folder in which the file will be stored.

Note also the "enctype" declaration and "file" input type. Together, these produce a form that let's you browse to, and then upload, a file.

The &action" will cause the "fileUpload.php" form handler to be run when the "Upload File" button is clicked.


<- Go to Part 1   Go to Part 3 ->







Go back to PHP Tutorials home page

Go back to Tutorials home page



Earnings Tracker is John Dixon Technology's FREE accounting / bookkeeping software tool.

Aimed at contractors and freelancers, Earnings Tracker enables you to perform bookkeeping and accounting tasks, helping you to keep track of your company's earnings and outgoings.

The software is written in PHP and MySQL and is available to use for FREE online, or as a FREE download.

Earnings Tracker can also be used simply as a dividend, corporation tax, or VAT calculator.

Need free accounting software
 


JDT

Copyright Notice for John Dixon Technology Ltd

Privacy Statement

Terms & Conditions