/ Published in: PHP

1. Edit the html form 'action' to point to your PHP page that handles the upload.
2. Create the php page with the code below
3. Define Paths in PHP lines: 3 , 4 of php file
4. Create matching folder to paths in #3 on server.
5. chmod that folder 777
6. Tweak to your liking.
2. Create the php page with the code below
3. Define Paths in PHP lines: 3 , 4 of php file
4. Create matching folder to paths in #3 on server.
5. chmod that folder 777
6. Tweak to your liking.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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){ echo "File Name : ".$HTTP_POST_FILES['ufile']['name'][0]." was uploaded <br />"; echo "File Size : ".$HTTP_POST_FILES['ufile']['size'][0]."<br />"; echo "File Type : ".$HTTP_POST_FILES['ufile']['type'][0]."<br /><br />"; }else{ echo "No File Uploaded <br /><br />"; } // output file info upon success or throw error if($filesize2 != 0){ echo "File Name :".$HTTP_POST_FILES['ufile']['name'][1]."<br />"; echo "File Size :".$HTTP_POST_FILES['ufile']['size'][1]."<br />"; echo "File Type :".$HTTP_POST_FILES['ufile']['type'][1]."<br />"; }else{ echo "2nd File Not Uploaded <br /><br />"; } ?>
URL: http://www.thatgrafix.com
Comments
