| 檔案上傳<?php 檔案上傳 $command=$_POST["command"]; if ($command==null) { 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"]; unlink($filename); if(copy($tempname,$filename)==1) echo "檔案上傳OK"; else echo "檔案上傳失敗"; } ?>
作業: 先以NOTEPAD建立一個檔案, 再將檔案上傳, 再讀取檔案內容顯示在螢幕
| |