/ Published in: PHP

URL: http://www.thatgrafix.com
- Edit the html form 'action' to point to your PHP page that handles the upload.
- Create the php page with the code below
- Define Paths in PHP lines: 3 , 4 of php file
- Create matching folder to paths in #3 on server.
- chmod that folder 777
- Tweak to your liking.
Expand |
Embed | Plain Text
use this html for the upload form: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>File Upload</title> <style type="text/css"> body {font-family:Lucida Grande, "Lucida Sans", arial; font-size:1.3em; color:#555;} </style> </head> <body> <table width="500" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <form action="upload_handle.php" method="post" enctype="multipart/form-data" name="form1" id="form1"> <td><table width="100%" border="0" cellpadding="8" cellspacing="8" bgcolor="#FFFFFF"> <tr> <td><strong>Multiple File Upload:<br /><span style="font-size:70%;">(*you dont have to upload more than one.)</span></strong></td> </tr> <tr> <td> File One <br /> <input name="ufile[]" type="file" id="ufile[]" size="50" /> </td> </tr> <tr> <td>File Two<br /> <input name="ufile[]" type="file" id="ufile[]" size="50" /></td> </tr> <tr> <td align="center"><input type="submit" name="Submit" value="Upload" /></td> </tr> </table></td> </form> </tr> </table> </body> </html> -------------------------- php <?php // define your paths below eg uploaded_files chmod that dir 777 $path1= "uploaded_files/".$HTTP_POST_FILES['ufile']['name'][0]; $path2= "uploaded_files/".$HTTP_POST_FILES['ufile']['name'][1]; // copy files to server // get sizes $filesize1=$HTTP_POST_FILES['ufile']['size'][0]; $filesize2=$HTTP_POST_FILES['ufile']['size'][1]; // output file info upon success or throw error if($filesize1 != 0){ }else{ echo "No File Uploaded <br /><br />"; } // output file info upon success or throw error if($filesize2 != 0){ }else{ echo "2nd File Not Uploaded <br /><br />"; } ?>
Comments

You need to login to post a comment.
good job Yà¹Y
Thanks. As I know from php tutorials the first thing is needed to do is create an HTML form that allows people to choose the file they want to upload. But most of scripts on web have only php code. One more thank