引用 | 編輯
dream0914
2011-09-26 16:24 |
樓主
|
||
x0
【類型】其他【版本】5.30 各位大大好,小弟目前練習寫一個上傳頁面,但執行結果卻顯示上傳失敗,小弟是初學者,不知哪邊程式寫錯,還請大大們指教 複製程式 <html> <head> <title>影片上傳</title> <meta http-equiv="Content-Type" cotent="text/html; charset=utf-8"> </head> <body> <center><b><i><h1>影片上傳</h1></i></b><p> <form action="upload_inf.php" method="post" name="form"> <fieldset align="center"> <legend><b>請輸入以下資訊</b></legend> <table align=center border=1> <tr><th width=80>學習等級:</b></th><th width=150><input type="radio" name="level" value="1"/>初階<input type="radio" name="level" value="2"/>進階</th></tr> <input type="hidden" name="MAX_FILE_SIZE" value="20971520"> <tr><th width=80>路徑:</b></th><th width=150><input type="file" size="30" name="videofile"/></th></tr> </table> </fieldset> <input type="submit" value="上傳"> <input type="reset" value="重新設定"> </form> </center> </body> </html> 複製程式 <?php //連接資料庫 $dbc = mysql_connect('localhost', 'root', '123', 'video'); //取得表單資訊 $level = $_POST['level']; $path = $_POST['path']; //檔案儲存路徑與檔名 $upload_dir = "C:/AppServ/www/video/"; $video_file = $upload_dir . $_FILES["videofile"]["name"]; //將上傳檔案由暫存目錄移至指定目錄 if (move_uploaded_file($_FILES["videofile"]["tmp_name"], $video_file)) { $query = "INSERT INTO save_inf (level, path)" . "VALUES('$level', '$path')"; mysql_query($dbc, $query) or die('資料庫無法連接'); //顯示資訊 echo "上傳成功 <hr>"; echo "檔案名稱 : " . $_FILES["videofile"]["name"] . "<br>"; echo "檔案大小 : " . $_FILES["videofile"]["size"] . "<br>"; echo "檔案類型 : " . $_FILES["videofile"]["type"] . "<br>"; echo "<p><a href='javascript:history.back()'>繼續上傳</a></p>"; mysql_close($dbc); } else { echo "<b>影片上傳失敗!!!</b><p>"; echo "<a href='javascript:history.back()'>重新上傳</a>"; } //關閉資料庫 mysql_close($dbc); ?> x0
|