Gary E. Terry wrote:
I have a problem. I have done this before, but can't find the files.
I am using the following function to upload files from a form.

foreach ($_FILES["pictures"]["error"] as $key => $error) {
   if ($error == UPLOAD_ERR_OK) {
       echo "$error_codes[$error]";
         "images/" .$_FILES["pictures"]["name"][$key]
       ) or die("Problems with upload");

I also need to insert the filenames of the uploaded files into a database.

There are three fields in my db for these filenames, image1 image2 and
What would be the best way to get those filenames from the array into the
vars $image1 $image2 and $image3?

You want variable variables:

for ($i = 1; $i < 5; $i++) {
  ${"image".$i} = "i is " . $i;
echo $image4 . "\n";

i is 4

so after the or die:

${"image".$key} = $_FILES['pictures']['name'];

Postgresql & php tutorials

PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to