我想一次选择更多图像文件并上传为 1,2,3,4,... 喜欢:
<form action="upload_file.php" method="post" enctype="multipart/form-data">
<input type="file" name="imgs[]" id="imgs" multiple/>
<input type="submit" name="submit" value="Submit" />
</form>
PHP代码:
<?php
if (file_exists("upload/" . $_FILES["imgs"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
//I think loop goes here
===================
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"]);
echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
===================
}
?>
==================================================== =================
这是作品...
<form action="upload_file.php" method="post" enctype="multipart/form-data">
<input type="file" name="uploads[]" multiple>
<input type="submit" name="submit" value="Submit" />
</form>
PHP
<?php
$count=1;
foreach ($_FILES['uploads']['tmp_name'] as $file) {
echo '<li>' . $file . '</li>';
copy($file, "uploads/" . $count.".jpg");
echo "Stored in: " . "uploads/" . $count.".jpg";
$count++;
}
?>
这是作品....