一键输入多个图像上传PHP表单

一键输入多个图像上传PHP表单,第1张

一键输入多个图像上传PHP表单

extract($_POST);
$error=array();
$extension=array(“jpeg”,”jpg”,”png”,”gif”);
foreach($_FILES[“files”][“tmp_name”] as $key=>$tmp_name) {
$file_name=$_FILES[“files”][“name”][$key];
$file_tmp=$_FILES[“files”][“tmp_name”][$key];
$ext=pathinfo($file_name,PATHINFO_EXTENSION);


    if(in_array($ext,$extension)) {        if(!file_exists("photo_gallery/".$txtGalleryName."/".$file_name)) { move_uploaded_file($file_tmp=$_FILES["files"]["tmp_name"][$key],"photo_gallery/".$txtGalleryName."/".$file_name);        }        else { $filename=basename($file_name,$ext); $newFileName=$filename.time().".".$ext; move_uploaded_file($file_tmp=$_FILES["files"]["tmp_name"][$key],"photo_gallery/".$txtGalleryName."/".$newFileName);        }    }    else {        array_push($error,"$file_name, ");    }}

并且您必须检查您的HTML代码

<form action="create_photo_gallery.php" method="post" enctype="multipart/form-data">    <table width="100%">        <tr> <td>Select Photo (one or multiple):</td> <td><input type="file" name="files[]" multiple/></td>        </tr>        <tr> <td colspan="2" align="center">Note: Supported image format: .jpeg, .jpg, .png, .gif</td>        </tr>        <tr> <td colspan="2" align="center"><input type="submit" value="Create Gallery" id="selectedButton"/></td>        </tr>    </table></form>


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5600093.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-15
下一篇 2022-12-15

发表评论

登录后才能评论

评论列表(0条)

保存