尝试使用PHP上传多个文件

时间:2020-11-06 09:53:41

标签: php file-upload

我编写了一个代码来创建目录并在其中上传文件,但问题是...即使我已经选择了多个文件,也只能上传1个文件。我要在其中上传多个文件。提前非常感谢您。这是我的代码:

<html>
<head>
<title>File upload</title>
</head>
<body>
<form action="#" method="post" enctype="multipart/form-data">
<input name="file" type="file" size="20" multiple= />
<br>
<label>Enter the folder name:</label>
<input type="text" name="foldername">
<br>
<input type="submit" name="submit" value="Upload">

</form>
</body>
</html>

<?php
if(isset($_POST['submit']))
{
    $foldername=$_POST['foldername'];

    $filename=$_FILES['file']['name'];

    $tmpname=$_FILES['file']['tmp_name'];

    $result = mkdir($foldername);

    if($result)
    {
        echo "created folder Successfully <br>";
    }
    else
    {
        echo "not created folder";
    }

    $row=move_uploaded_file($tmpname,"$foldername/$filename");

    if($row)
    {
        echo "succesffully uploaded";
    }
    else
    {
        echo "failed to upload";
    }

}
?>

0 个答案:

没有答案