这是官方的上传图片的代码,请问我怎么循环出多张图片的上传地址啊
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
echo "success";
$ret=array('strings'=>$_POST,'error'=>'0');
$fs=array();
foreach ( $_FILES as $name=>$file ) {
$fn=$file['name'];
$ft=strrpos($fn,'.',0);
$fm=substr($fn,0,$ft);
$fe=substr($fn,$ft);
$fp='files/'.$fn;
$fi=1;
while( file_exists($fp) ) {
$fn=$fm.'['.$fi.']'.$fe;
$fp='files/'.$fn;
$fi ;
}
move_uploaded_file($file['tmp_name'],$fp);
//$q=$fp[0];
//$w=$fp[1];
//$e=$fp[2];
$fs[$name]=array('name'=>$fn,'url'=>$fp,'type'=>$file['type'],'size'=>$file['size']);
}
$sql="INSERT INTO `weishichang`.`goods` `picture`,`picture2`,`picture3`) VALUES ('$easyinfo', '','','')";
$query=mysqli_query($conn, $sql);
$ret['files']=$fs;
//echo json_encode($fp);
echo $fp;
echo json_encode($ret);
}else{
echo "{'error':'Unsupport GET request!'}";
}
?>
0 个回复