萬盛學電腦網

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

php最簡單的文件上傳代碼

php最簡單的文件上傳代碼

<?php
   include("top.txt");
   include("scripts.txt");

   if(isset($_FILES['ufile']['name'])){
       echo "Uploading: ".$_FILES['ufile']['name']."<br>";

       $tmpName = $_FILES['ufile']['tmp_name'];
       $newName = UPLOADEDFILES . $_FILES['ufile']['name'];  

       if(!is_uploaded_file($tmpName) || !move_uploaded_file($tmpName, $newName)){
            echo "FAILED TO UPLOAD " . $_FILES['ufile']['name'] .
                 "<br>Temporary Name: $tmpName <br>";
       } else {
            echo "File uploaded.  Thank you!";
       }

   } else {
     echo "You need to select a file.  Please try again.";
  }
   include("bottom.txt");
?>

copyright © 萬盛學電腦網 all rights reserved