This is a simple PHP uploading file tutorial. You can upload files on your server through this script.
Overview
In this tutorial create 2 files
1. upload.php
2. upload_ac.php
Step
1. Create file upload.php.
2. Create file upload_ac.php.
3. Create folder “upload” for store uploaded files.
4. CHMOD your upload folder to “777″ by using your ftp software(change permission).
Step1:
Create file upload.php

|—|——————— code ——————–|—|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
<table width="500" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"><br> <tr><br> <form action="upload_ac.php" method="post" enctype="multipart/form-data" name="form1" id="form1"><br> <td><br> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"><br> <tr><br> <td><strong>Single File Upload </strong></td><br> </tr><br> <tr><br> <td>Select file <br> <input name="ufile" type="file" id="ufile" size="50" /></td><br> </tr><br> <tr><br> <td align="center"><input type="submit" name="Submit" value="Upload" /></td><br> </tr><br> </table><br> </td><br> </form><br> </tr><br> </table></p>
Step2:
Create file upload_ac.php
|—|——————— code ——————–|—|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
<p><?php<br>
//set where you want to store files<br>
//in this example we keep file in folder upload <br>
//$HTTP_POST_FILES['ufile']['name']; = upload file name<br>
//for example upload file name cartoon.gif . $path will be upload/cartoon.gif<br>
$path= "upload/".$HTTP_POST_FILES['ufile']['name'];<br>
if($ufile !=none)<br>
{<br>
if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path))<br>
{<br>
echo "Successful<BR/>"; </p>
<p>//$HTTP_POST_FILES['ufile']['name'] = file name<br>
//$HTTP_POST_FILES['ufile']['size'] = file size<br>
//$HTTP_POST_FILES['ufile']['type'] = type of file<br>
echo "File Name :".$HTTP_POST_FILES['ufile']['name']."<BR/>"; <br>
echo "File Size :".$HTTP_POST_FILES['ufile']['size']."<BR/>"; <br>
echo "File Type :".$HTTP_POST_FILES['ufile']['type']."<BR/>"; <br>
echo "<img src=\"$path\" width=\"150\" height=\"150\">";<br>
}<br>
else<br>
{<br>
echo "Error";<br>
}<br>
}<br>
?></p>
Step3:
CHMOD upload folder to 777 (change permission)
This step, do it when you upload to real server. This example, I use CuteFTP, right click at upload folder > FTP Commands > CHMOD












April 28, 2010 at 7:39 am
Simple and excellent tutorial
April 29, 2010 at 8:04 am
Excellent tutorial, I like the simple ones.
April 29, 2010 at 9:00 am
Thank’s for sharing !
April 30, 2010 at 4:53 am
Great useful tip. Thanks a lot for sharing
May 2, 2010 at 9:48 pm
Terrific work! This is the type of information that should be shared around the web. Shame on the search engines for not positioning this post higher!
June 3, 2010 at 7:24 pm
Great information! I’ve been looking for something like this for a while now. Thanks!
June 21, 2010 at 2:04 am
found your site on del.icio.us today and really liked it.. i bookmarked it and will be back to check it out some more later
July 16, 2010 at 12:57 am
Thanks! really useful.
August 2, 2010 at 8:41 pm
thank for tutorial
December 22, 2010 at 11:07 am
Nice site, nice and easy on the eyes and great content too.