Hi All,

I found this code to copy files to a directory on my server, but I cant figure out one part.

$ID = mysql_insert_id();
printf("Last inserted record has id %d\n", mysql_insert_id()); //test it

//  Now you can use that ID to change the file names of the two files that were
//  attached when the file was uploaded
$filename1 = "/home/website/public_html/staff/uploads/" . $ID . "-" . $FILE1_name ;
$filename2 = "/home/website/public_html/staff/uploads/" . $ID . "-" . $FILE2_name ;

@copy("$FILE1" , $filename1);
@copy("$FILE2" , $filename2);

This is the part I cant figure what it is or why its there?

$FILE1_name

Where is this coming from? How does, $FILE1_name become--> flower.jpg?

I must be missing something simple here.

If a variable is undefined, like this is I should end up with something like...

/home/website/public_html/staff/uploads/143- <--- then nothing for the filename.

Sorry, but it is annoying when something works, and I must just rely on it and not understand it.

Thanks a bunch.

Don

    its using an upload form that populates the $_FILE global array, you can ignore that, if its all local just look at the copy function in the manual

      To expand on dagon's reply

      dagon wrote:

      its using an upload form that populates the $_FILE global array,

      The script is using the deprecated register_globals method of accessing the uploaded files and their names, and (without any sort of validation, even the bare minimum of using move_uploaded_file() instead of copy()) copying the files from one place to another (silently suppressing any errors that occur as a result of the attempt. Now that's classy).

        Thanks dagon.

        And Weedpacket, I gotta ask you. What's your IQ????

        You NEVER cease to amaze me.

        Thanks for that precise, and classy explanation.

        Always grateful,

        Don

          Write a Reply...