💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
PHP+input表单实现多文件上传代码如下: html部分: <form action="test.php" method="post" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="1000000" /> <input type="file" name="file[]" value="" /> <input type="file" name="file[]" value="" /> <input type="file" name="file[]" value="" /> <input type="submit" name="sub" value="上传文件" /> </form> php部分: if($_POST['sub']=='上传文件'){ echo '<pre>'; print_r($_FILES); function delEmpty($v){ return $v!=''; } $newUpFileName = array_filter($_FILES['file']['name'],'delEmpty'); print_r($newUpFileName); $dirName = 'upload/images/'.date('ymd'); if(!is_dir($dirName)){ mkdir($dirName,0777,1); } foreach($newUpFileName as $k=>$v){ if(is_uploaded_file($_FILES['file']['tmp_name'][$k])){ $upFileDir = $dirName.'/'.$_FILES['file']['name'][$k]; if(move_uploaded_file($_FILES['file']['tmp_name'][$k],$upFileDir)){ echo '<script type="text/javascript"> alert("上传并移动成功!"); history.go(-1); </script>'; }else{ echo '<script type="text/javascript"> alert("移动失败!"); history.go(-1); </script>'; } }else{ echo '<script type="text/javascript"> alert("不是通过http post上传的文件,请重新操作"); history.go(-1); </script>'; } } }