主页 M

PHP图片上传的实例代码

2020-02-26 网页编程网 网页编程网
<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
error_reporting(0);
if($_POST['upload']=='Send'){
$dest_folder = "file/logo/";
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);
}
}
}
?>
阅读原文
阅读 2570
123 显示电脑版