I want to parse $ _files vector to upload a multiple. I try this way:
for ($ i = 0; $ i & lt; counts ($ _ files ['product_image']); $ i ++) {PRINT_R ($ _ Files ['product_image'] [$ i]); But it gives me an error: Undefined offsets: 0 in / user .... etc then I have a form for 1, 3, etc. Three fields:
& lt; Input id = "product_image" type = "file" name = "product_image []" & gt; & Lt; Input id = "product_image" type = "file" name = "product_image []" & gt; & Lt; Input id = "product_image" type = "file" name = "product_image []" & gt; I wonder where I am wrong? Can not you parse $ _files vector?
Did you try to use a foreach loop?
See:
& lt; Form action = "" method = "post" enctype = "multipart / form-data" & gt; & Lt; P & gt; Image: & lt; Input type = "file" name = "image []" /> & Lt; Input type = "file" name = "image []" /> & Lt; Input type = "file" name = "image []" /> & Lt; Input type = "submit" value = "send" /> & Lt; / P & gt; & Lt; / Form & gt; & Lt ;? Php foreach ($ _FILES ["picture"] ["error"] $ key = & gt; $ error) {if ($ error == UPLOAD_ERR_OK) {$ tmp_name = $ _FILES ["picture"] ["tmp_name "] [$ Key]; $ Name = $ _FILES ["picture"] ["name"] [$ k]; Move_uploaded_file ($ tmp_name, "data / $ name"); }}? & Gt; Perhaps your first loop can work like this: file_count = count ($ _ FILES ['product_image'] ] ['error' ]); ($ I = 0; $ i
Comments
Post a Comment