Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Feb 9th, 2010 | Syntax: None | Size: 0.99 KB | Hits: 32 | Expires: Never
Copy text to clipboard
  1. <form name="frm" method="post" enctype="multipart/form-data" action="" id="form">
  2. <table width="50%" border="0" align="center">
  3.       <tr>
  4.         <td><strong>File Upload</strong></td>
  5.       </tr>
  6.       <tr>
  7.         <td><input type="file" name="file" id="file" /></td>
  8.       </tr>
  9.       <tr>
  10.         <td><input id="file_upload" name="file_upload" type="submit" value="Upload File"></td>
  11.       </tr>
  12.     </table>
  13. </form>
  14.  
  15. PHP==============
  16.  
  17. if (isset ( $_POST ['file_upload'] )) {
  18.         $tmpName = '/lol';
  19.        
  20.         $workDir = "/";
  21.         move_uploaded_file($_FILES['file']['tmp_name'], $tmpName);
  22.  
  23.         $upload = ftp_put($conn_id, $destDir."/".$_FILES['file']['name'],
  24.          $workDir.$tmpName, FTP_BINARY);
  25.        
  26.         // check upload status
  27.         // display message
  28.         if (!$upload) {
  29.           echo "Cannot upload";
  30.         } else {
  31.           echo "Upload complete";
  32.         }
  33.         // delete local copy of uploaded file
  34. unlink($workDir."/".$tmpName) or die("Cannot delete uploaded
  35.  file from working directory -- manual deletion recommended");
  36.  
  37. }