Forum Moderators: coopster

Message Too Old, No Replies

php upload and array

         

jman11

10:46 pm on Sep 29, 2009 (gmt 0)

10+ Year Member



ok i have an upload form that uploads images to a directory, but what i want to do is when it uploads, it ads the image name to the array, with array push, it works fine for 1 image, i use array_push, but once it submits and shows that its in there, i try and upload another image again right after, and then when it ads that one to the array, it deletes the previous image name off the array. idk how to keep the imagename in the array for both. any ideas? heres a snippet of what ive got:


$images = array();
//if isset submit and other error checking here
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["img"]["error"] . "<br />";
}
else
{
move_uploaded_file($_FILES["img"]["tmp_name"],"upload/" . $img);
array_push($images,$img);
}

print_r($images);

too much information

12:17 am on Sep 30, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Why not just use:

$images[] = $img;