avario Posted December 2, 2009 Share Posted December 2, 2009 I have made a form that uploads images to a directory that I specify. But does anyone know what will happen if the image being uploaded has the same name as one that has previously been uploaded? Will it replace the previous image, not upload or upload using a different name? It would be very helpful if someone could tell me, Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/183682-uploaded-image-name-repetition/ Share on other sites More sharing options...
.josh Posted December 2, 2009 Share Posted December 2, 2009 depends on the chmod of the pic but more than likely you will overwrite the previous one. Quote Link to comment https://forums.phpfreaks.com/topic/183682-uploaded-image-name-repetition/#findComment-969548 Share on other sites More sharing options...
avario Posted December 2, 2009 Author Share Posted December 2, 2009 Thanks for the reply. I think I will just call each image a unique number to avoid the problem. Quote Link to comment https://forums.phpfreaks.com/topic/183682-uploaded-image-name-repetition/#findComment-969587 Share on other sites More sharing options...
jcombs_31 Posted December 2, 2009 Share Posted December 2, 2009 Just use a counter. During the upload process check if the file exists, if it does just increment a counter. e.g., image.jpg image1.jpg image2.jpg Quote Link to comment https://forums.phpfreaks.com/topic/183682-uploaded-image-name-repetition/#findComment-969903 Share on other sites More sharing options...
.josh Posted December 2, 2009 Share Posted December 2, 2009 or just append the current timestamp to the name. That will ensure uniqueness and the timestamp might come in handy later. Quote Link to comment https://forums.phpfreaks.com/topic/183682-uploaded-image-name-repetition/#findComment-969923 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.