![]() |
溫瑞烘老師的教學歷程檔案(Teaching ePortfolio) - 104-1-資料庫程式設計-基礎 - 第12週-Form-File-檔案上傳 |
| 第12週-Form-File-檔案上傳<?php檔案上傳 $command=$_POST["command"]; if ($command=="") { echo"<html><body><center> <form method=post enctype=multipart/form-data action=$SELF_PHP> 選取檔案: <input type=file name=filename><br> <input type=submit name=command value=送出> <input type=reset name=command value=清除> </form></center></body></html>"; } if ($command=="送出") { $filename=$_FILES["filename"]["name"]; $tempname=$_FILES["filename"]["tmp_name"]; $target="./ftp/$filename"; if (file_exists($target)) unlink($target); // 刪除檔案 if (!move_uploaded_file($_FILES["filename"]["tmp_name"], $target)) { echo "<center><font color=red> <b>上傳檔案失敗,請檢查後再試</b></center></font>"; die(); } else echo "檔案已經上傳"; } ?> 作業:擴充前述程式, 檔案上傳成功後出現按鈕 開啟檔案 將檔案內容讀出顯示在螢幕
|
|
中華科技大學數位化學習歷程 - 意見反應 | ![]() |