input file用了multiple属性,怎么用PHP上传?
以下在PHP文件中获得的文件个数始终为0-----------------------------------------------------------------...
以下在PHP文件中获得的文件个数始终为0
---------------------------------------------------------------------------------------------------------------------------------
upload.html:
---------------------------------------------------------------------------------------------------------------------------------
<div class="upload">
<form name="file_form" method="post" action="upload.php" enctype="multipart/form-data" target="_blank">
<input type="file" name="upload_files[]" /><inpput type="submit" value="上传">
</form>
</div>
---------------------------------------------------------------------------------------------------------------------------------
upload.php:
---------------------------------------------------------------------------------------------------------------------------------
<?php
echo count($upload_files);
?>
--------------------------------------------------------------------------------------------------------------------------------- 展开
---------------------------------------------------------------------------------------------------------------------------------
upload.html:
---------------------------------------------------------------------------------------------------------------------------------
<div class="upload">
<form name="file_form" method="post" action="upload.php" enctype="multipart/form-data" target="_blank">
<input type="file" name="upload_files[]" /><inpput type="submit" value="上传">
</form>
</div>
---------------------------------------------------------------------------------------------------------------------------------
upload.php:
---------------------------------------------------------------------------------------------------------------------------------
<?php
echo count($upload_files);
?>
--------------------------------------------------------------------------------------------------------------------------------- 展开
1个回答
展开全部
//PHP文件上传
<?php
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 20000))
{
if ($_FILES["file"]["error"] > 0)
{
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("upload/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"]);
echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
}
}
}
else
{
echo "Invalid file";
}
?>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询