Script Example - Uploading a file using PHP

You can use the following script to upload files using a PHP Script:
(Make sure you set the correct file permissions to the directory that you choose to upload the file too.)

<center><font size=6 face=tahoma>phpSimpleUpload<font size='2'><br>A simple script for uploading files!<br><br>
<? if (! ISSET($_POST['upload'])){ ?>
<center><form method="POST" enctype="multipart/form-data" action="upload.php">
<table border="0" width="500" cellpadding="7">
<tr>
<td width="100%" bgcolor="#EEF1F7">
<p align="center"><b><font face="Tahoma" size="2">Please make sure that the files you are uploading do <br>not have the same name as other files you have uploaded!</font></b>
<tr>
<td width="100%" bgcolor="#E1E6F0">
<p align="center"><b><font face="Tahoma" size="2">Upload
Options</font></b></td>
</tr>
<tr>
<td width="100%" bgcolor="#EEF1F7">
<table border="0" width="100%" cellpadding="4">
<tr>
<td width="34%" align="right" bgcolor="#E1E6F0" valign="top"><font face="Tahoma" size="2"><b>Select
File To Upload:</b></font></td>
<td width="66%" bgcolor="#EAEDF4">
<input type="hidden" name="MAX_FILE_SIZE" size="5200000">
<input type="file" name="upload1" size="29"><br>
<input type="file" name="upload2" size="29"><br>
<input type="file" name="upload3" size="29"><br>
<input type="file" name="upload4" size="29"><br>
<input type="file" name="upload5" size="29"></td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</div>
<p align="center"><input type="submit" value="Upload Files" name="upload"></p>
</form>
<? } else { ?>
<div align="center">
<center>
<table border="0" width="500" cellpadding="7">
<tr>
<td width="100%" bgcolor="#E1E6F0">
<p align="center"><b><font face="Tahoma" size="2">Upload
Information</font></b></td>
</tr>
<tr>
<td width="100%" bgcolor="#EDF1F8">
<table border="0" width="100%" cellspacing="3" cellpadding="6">
<tr>
<td width="25%" bgcolor="#E6EAF2" align="center"><b><font face="Tahoma" size="2">File
Name</font></b></td>
<td width="25%" bgcolor="#E4EAF3" align="center"><b><font face="Tahoma" size="2">Size</font></b></td>
<td width="25%" bgcolor="#E4EAF3" align="center"><b><font face="Tahoma" size="2">Type</font></b></td>
<td width="25%" bgcolor="#E4EAF3" align="center"><b><font face="Tahoma" size="2">Upload</font></b></td>
</tr>
<?
$error = "";
//#################################RUN THROUGH UPLOAD PROCESS#################################
for ($num=1;$num<=5;$num++){
if (! $_FILES['upload'.$num]['name'] == ""){
move_uploaded_file($_FILES['upload'.$num]['tmp_name'], $_FILES['upload'.$num]['name']) or $error = "Not A";
print "<tr><td width='25%' bgcolor='#E4EAF3' align='center'><font face='Tahoma' size='2'>".$_FILES['upload'.$num]['name']."</td><td width='25%' bgcolor='#E4EAF3' align='center'><font face='Tahoma' size='2'>".$_FILES['upload'.$num]['size']." bytes</td><td width='25%' bgcolor='#E4EAF3' align='center'><font face='Tahoma' size='2'>".$_FILES['upload'.$num]['type']."</td><td width='25%' bgcolor='#E4EAF3' align='center'><font face='Tahoma' size='2'>".$error."Sucess</td></tr>";
}
}
//############################################################################################
?>
</table>
</td>
</tr>
</table>
</center>
</div>
<? } ?>

Add Feedback