<form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<table align="center">
<tr>
<td>Title :</td>
<td><input type="text" name="title" size="150" value= "" /> </td>
</tr>
<tr>
<td>Choose a file to upload: </td>
<td><input type="file" name="file" id="file"/></td>
</tr>
<tr>
<td><input type="submit" name="submit" value="Upload File" /></td>
</tr>
</table>
</form>
我的PHP:
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
if ($_FILES["file"]["error"] > 0)//get error on here when upload video
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
}
else
{
// echo "Upload: " . $_FILES["file"]["name"] . "<br>";
// echo "Type: " . $_FILES["file"]["type"] . "<br>";
/* echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br>";
*/
if (file_exists("pdf/" . $_FILES["file"]["name"]))//get error on here when upload video
{
//echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"pdf/" . $_FILES["file"]["name"]);
}}}
我可以使用此代码上传 pdf、图像、mp3 文件,但无法上传视频我收到错误消息:“注意:未定义索引:文件在”如何消除此错误?请帮忙......