我想上传视频,音频,图像,pdf,ppt,word文件,然后将它们保存到一个目录中......这是我的上传代码,.,,,没有错误但也没有输出......当我打开文件夹,里面没有图像文件……另外,如果你们告诉我应该如何上传 pdf、word 和视频文件,那将非常有帮助……
继承人我到目前为止:
这是 add-material.php
<form id="form" method="post" action="add-material-action.php" enctype="multipart/form-data">
<label for="file">Upload Your File Here:</label><input type="file" name="uploadedfile" id="uploadedfile"/><br /><br />
<input class="mybutton" type="submit" name="Add Material" class="button" value="Add Material" />
因为我的表格很大所以我在这里粘贴相关的代码行
这是 add-material-action.php
$allowedExts = array("jpg", "jpeg", "gif", "png");
$extension = end(explode(".", $_FILES["uploadedfile"]["name"]));
if (( ($_FILES["uploadedfile"]["type"] == "image/gif")
|| ($_FILES["uploadedfile"]["type"] == "image/jpeg")
|| ($_FILES["uploadedfile"]["type"] == "image/png")
|| ($_FILES["uploadedfile"]["type"] == "image/pjpeg"))
&& ($_FILES["uploadedfile"]["size"] < 20000)
&& in_array($extension, $allowedExts))
{
if ($_FILES["uploadedfile"]["error"] > 0)
{
echo "Return Code: " . $_FILES["uploadedfile"]["error"] . "<br />";
}
elseif (file_exists("learningmaterial/" . $_FILES["uploadedfile"]["name"]))
{
echo $_FILES["uploadedfile"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["uploadedfile"]["tmp_name"],
"learningmaterial/" . $_FILES["uploadedfile"]["name"]);
echo "Stored in: " . "learningmaterial/" . $_FILES["uploadedfile"]["name"];
}
}
else
{
echo "Invalid file";
}
提前谢谢:)