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

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -