WordPress企业主题定制/开发/优化

PHP批量上传图片的实例教程

首页 » PHP » PHP批量上传图片的实例教程

China Mould suppliers of Mould, plastic injection molding,China Mould exporter of Mould, injection molding company,
china mould makers,china plastic injection molding, china injection molding company
深圳外贸网站建设, wordpress企业主题, 深圳网页设计
Peony, Peony picture, Yellow peony

批量上传图片,一次性上传图片,下面是实例:

代码:
<html>
<head><title>upload picture more once</title></head>
<body>
<form action="" method="post" enctype="multipart/form-data">
<p>Pictures:<br />
<input type="file" name="pictures[]" /><br />
<input type="file" name="pictures[]" /><br />
<input type="file" name="pictures[]" /><br />
<input type="submit" name="upload" value="Send" />
</p>
</form>
</body>
</html>
<?php
if($_POST['upload']=='Send'){
$dest_folder = "picture/";
if(!file_exists($dest_folder)){
mkdir($dest_folder);
}
foreach ($_FILES["pictures"]["error"] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
$tmp_name = $_FILES["pictures"]["tmp_name"][$key];
$name = $_FILES["pictures"]["name"][$key];
$uploadfile = $dest_folder.$name;
move_uploaded_file($tmp_name, $uploadfile);
}
}
}
?>

可以试一下。

相关项目

  • WordPress外贸企业主题

  • 最近更新

  • 热门标签