【类型】其他
【版本】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);
?>