Gossamer Forum
Home : Products : DBMan : Customization :

Multiple File Upload- Renaming Files

Quote Reply
Multiple File Upload- Renaming Files
I have the multiple file upload mod working great, with the Fix to allow the files to be displayed at different positions.
However, since the images may have different filenames, and the array used seems to just read the images in the order they are in the directory, the images may appear in the wrong location.

Does anyone know of a modification to the
sub validate_upload subroutine that could rename the images to say 1.gif, 2.gif, 3.gif etc

Trev

Quote Reply
Re: Multiple File Upload- Renaming Files In reply to
Please disregard my question. I found my answer at:

http://www.gossamer-threads.com/perl/forum/showthreaded.pl?Cat=&Board=DBCust&Number=95905

Trev

Quote Reply
Re: Multiple File Upload- Renaming Files In reply to
Hi,TrevR
Did you success with it??
I failed could you please tell me the trick?


Please Excuse me for my poor knoledge of PERL
Regards,
Act.
Quote Reply
Re: Multiple File Upload- Renaming Files In reply to
yes, it worked for me. There wasn't any trick.
However, you should make sure that the multiple file upload mod is working before you add these changes.
Then you will know which part has a problem or error


Trev

Quote Reply
Re: Multiple File Upload- Renaming Files In reply to
Ok, thank you for reply :-)
Let me show what was added to my modify,I got from the thread you gave;
=============code from JPDeni===========
In your .cfg file, set up an array with the names that you want to give the pics:

$newfile[1] = "photo";
$newfile[2] = "works";

Notice that you need to start with number 1 and that you must have an entry in the array for as many files as you allow to be uploaded.

In db.cgi, sub validate_upload, before

if (!open(OUTFILE, ">$SAVE_DIRECTORY\/$newdirname\/$filename")) {

add

$filename = $newfile[int($Number)] . substr($filename,index($filename,"."));
=============end code from JPDeni===========
Before adding this modify ,the multiple upload is working fine but after I modify it it not turn the name to new file name.,but keep the naem as it original.

Any idea?


Please Excuse me for my poor knoledge of PERL
Regards,
Act.