Thread: Advice please.
View Single Post
Old September 30th, 2005, 04:32 AM   #1 (permalink)
garybrun
Member
Verified Customer
 
Join Date: Dec 2002
Location: Norway
Posts: 118
Advice please.

I have a modified version of classified that I am running as a photo record database (three images per record.) Users upload their images to one category and then an administrator moves the record to the most suitable category (there are lots.) Using Classified in this way has produced a bug which I can’t seem to fix. If a user uploads two images with the same name to the same category, the second image is refused and a warning message about duplicate images is displayed (No problem there.) But the bug occurred if they upload an image and Admin move it into the correct category, if they then upload a second image named the same and admin also move it into the same category (with the first image,) the first recorded images are over writen and the database entry becomes corrupted.

This is my understanding on how this works.
Each image is renamed with the user-number added to the front of the image name (e.g. user 666 uploads image.jpg that is renamed 666image.jpg.) These files are stored in a directory named by the category-number within the data directory. When you move a record from one category to another, the images are moved from one category directory to another… overwriting any files with the same file name.

I need to fix this and can see two avenues to pursue.
1) Each image needs to be uploaded with a unique name, perhaps utilising the date Function time(). So the image.jpg uploaded by user 666 would be renamed 666958950466image.jpg.
I would have thought this would’ve been quite easy to achieve, but three hours in, I am loosing too much hair to keep trying.
2) So how about utilising a function already available? When a record is moved from one category to another, a check is done for existing files named the same, before the move is implemented. Here is the function move_image() in the pp-inc.php.

Code:
Content visible to verified customers only.
In uploadproduct.php this script handles the duplicate image check;

Code:
Content visible to verified customers only.
Is it possible to adjust the first script to check for existing files before overwriting them?

Please could you advise which avenue I should pursue and if anyone has already fixed this please advice.

Last edited by garybrun; September 30th, 2005 at 04:35 AM.
garybrun is offline   Reply With Quote