| 第十二週檔案上傳與滿意度調查<?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> <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 "檔案已經上傳"; } ?> 作業: 先以NOTEPAD建立一個滿意度調查的題目儲存為檔案, 再將檔案上傳, 再讀取檔案內容 丟出題目做問卷調查 | |