January 13, 201115 yr Ok im stumped and thats why im here, i have a form with 6 images to upload. I have done these in arrays to save code. This all works but i noticed with errors turned on it brings up Warning: Cannot use a scalar value as an array in *blah* on line 61; heres the code LOTS OF OTHER CODE UP HERE $imgs = array("1", "2", "3", "4", "5", "6"); foreach($imgs as $imgnum){ if (!empty($_FILES["picture".$imgnum])&∅($error)){ $ext = strtolower(strrchr($_FILES["picture".$imgnum]['name'], '.')); $type = $_FILES["picture".$imgnum]['type']; $filesize = filesize($_FILES["picture".$imgnum]['tmp_name']); if (empty($_POST["label".$imgnum])){ $error["label".$imgnum] = "You must add a title for your image."; } else if ($filesize >= $maxfilesize){ $error["pic"] = $lang['pictures_error_maxsize']; } LOTS MORE CODE DOWN HERE any pointers? Edited January 13, 201115 yr by JSweete
January 23, 201115 yr Ok im stumped and thats why im here, i have a form with 6 images to upload. I have done these in arrays to save code. This all works but i noticed with errors turned on it brings up Warning: Cannot use a scalar value as an array in *blah* on line 61; heres the code LOTS OF OTHER CODE UP HERE $imgs = array("1", "2", "3", "4", "5", "6"); foreach($imgs as $imgnum){ if (!empty($_FILES["picture".$imgnum])&∅($error)){ $ext = strtolower(strrchr($_FILES["picture".$imgnum]['name'], '.')); $type = $_FILES["picture".$imgnum]['type']; $filesize = filesize($_FILES["picture".$imgnum]['tmp_name']); if (empty($_POST["label".$imgnum])){ $error["label".$imgnum] = "You must add a title for your image."; } else if ($filesize >= $maxfilesize){ $error["pic"] = $lang['pictures_error_maxsize']; } LOTS MORE CODE DOWN HERE any pointers? The error message you get accures when you treat something as an array , which is not an array, but an integer, or maybe something with a value null. I am not sure, but try to check if a file is uploaded like this: if($_FILES["picture".$imgnum]['error']==0) { // your code comes here }
February 1, 201115 yr Author The error message you get accures when you treat something as an array , which is not an array, but an integer, or maybe something with a value null. I am not sure, but try to check if a file is uploaded like this: if($_FILES["picture".$imgnum]['error']==0) { // your code comes here } it was exactly that, i had miss declared some error report variables, all sorted now thanks for your help
Create an account or sign in to comment