The script is generating a filename based on the id and then copies the
file from somewhere to the new location. It's doing just what it's
supposed to. IF you don't want it to do it, just use the following
instead: 

//
                // Insert the photo details into the database
                //

                $result = mysql_query("INSERT INTO photo

        (id,galleryid,title,size_in_MB,person,filename,description) 
VALUES

        ('','$galleryid','$title','$size_in_MB','$person','$photo', 
                                '$description')
                        ");

That should do it. You should be using the $photo variable as the
filename and not moving anything. Of course this doesn't address the
thumbnail issue, but you get the idea. 

-Micah

                
On Sat, 2003-01-04 at 13:55, Mike C wrote:

> Hi,
> 
> I hope someone can help me with this.
> 
> I am trying to modify this portion of a script so that I can upload 
> photos (MacOSX 10.2.3) but keep the file names intact. At the moment 
> everything works fine except that when I upload photos, the script 
> changes the name of the file I just uploaded to a new filename 
> (sequentially) based on the database 'id' number to 1.gif, 2.gif, 
> 3.gif and so on.
> 
> I need to be able to keep the filename as it is (05-01.gif, 23-02.gif 
> etc) when I upload it!
> 
> //
>               // Insert the photo details into the database
>               //
> 
>               $result = mysql_query("INSERT INTO photo
>  
>       (id,galleryid,title,size_in_MB,person,filename,description) 
> VALUES
>  
>       ('','$galleryid','$title','$size_in_MB','$person','$filename', 
>                               '$description')
>                       ");
> 
>               //
>               // Retrieve the ID of the photo
>               //
> 
>               $result = mysql_query("SELECT * FROM photo
>                       WHERE galleryid = '$galleryid'
>                       AND title = '$title'
>                       AND description = '$description'");
>               $id = mysql_result($result,0,"id");
> 
>               //
>               // Generate a filename for the file
>               //
> 
>               $filename = "$id.$format";
> 
>               //
>               // Alter the database record to point to the correct
>               // filename.
>               //
> 
>               $result = mysql_query("UPDATE photo SET filename = '$filename'
>                               WHERE id = '$id'");
> 
>               //
>               // Move the thumbnail and full-sized photo to the 
> correct filesystem
>               // location.
>               //
> 
>               copy ($photo,"$filepath/$galleryid/photos/$id.$format");
>               copy 
> ($thumbnail,"$filepath/$galleryid/thumbnails/$id.$format");
> 
>               //
>               // Print out a Success message to the user.
>               //
> 
> Regards
> Mike
> -- 
> --------------------------------------------------------------
> Mike C
> Macintosh Support Specialist
> University of Otago (ITS)
> Dunedin
> NEW ZEALAND
> http://www.otago.ac.nz
> --------------------------------------------------------------

-- 
Raincross Technologies
Development and Consulting Services
http://www.raincross-tech.com

Reply via email to