萬盛學電腦網

 萬盛學電腦網 >> 網絡編程 >> php編程 >> php最簡單文件上傳代碼

php最簡單文件上傳代碼

我們實現最簡單的文件上傳功能,只要利用php教程自帶的move_uploaded_file函數就可以方便實現

 

<?php
     $tmp_filename = $_FILES['myupload']['tmp_name'];
     if(!move_uploaded_file($tmp_filename,"/path/to/dest/{$_FILES['myupload']['name']}")) {
          echo "An error has occurred moving the uploaded file.<BR>";
          echo "Please ensure that if safe_mode is on that the " . "UID PHP is using matches the file.";
          exit;
     } else {
          echo "The file has been successfully uploaded!";
     }
?>
copyright © 萬盛學電腦網 all rights reserved