php - Uploading images inside array not working -
i want upload multiple images. img[]
contains image files uploaded.the values inserted database imploded commas(,)
.but images not uploaded specified folder named photos
.
<input type="file" name="img[]" id="img[]" /> $n=$_files["img"]["name"]; $t=$_files["img"]["tmp_name"]; $image=implode(",",$n); $ex=explode(",",$image); $i=0; foreach($ex $item) { move_uploaded_file($_files["img[$i]"]["tmp_name"],"photos/$ex[$i]"); $i++; }
i think correct code should
<input type="file" name="img[]" id="img[]" /> $n=$_files["img"]["name"]; $t=$_files["img"]["tmp_name"]; $image=implode(",",$n); // no need explode here foreach($n $key=>$item) { //name there in $items // use temp_name of same file using name using $_files["img"]["tmp_name"][$key] move_uploaded_file($_files["img"]["tmp_name"][$key],"photos/$item"); }
Comments
Post a Comment