wdepot Posted February 25, 2006 Posted February 25, 2006 In managing our online store I've discovered instances where users adding products to our store have accidentally overwritten the images for other products already in the store because the file name used for the new product's image was the same as the file name for the existing product's image. How do I prevent this from happening? Basically what I would like to happen is, if Product 1 has an image named x.jpg, then only uploading a new image for Product 1 with the same name should be allowed to overwrite x.jpg. If another product is created (or modified) with the image file name x.jpg then the new file should be renamed automatically when it is copied by the uploading function from the temporary directory to the images directory and that new name be stored as the product's image file name. Let's say I am modifying Product 2 with a new image and the new image file I am uploading is named x.jpg, as is the existing image file for Product 1. When I click the Preview button the software should find that the file name x.jpg already exists and does not currently belong to Product 2. The uploaded file then should be renamed x-1.jpg. If x-1.jpg already exists then try x-2.jpg, then x-3.jpg and so on until there is no conflicting file name. If someone can tell me how to modify categories.php to do this or point me to an already written upload I would appreciate it.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.