PHP file rename

Sk8

New Member
I have a form where an admin will upload three pictures with different dimensions to three different designated directories. now to make sure that i don't get into the problem of duplicate file names i implemented something like the php will compare the uploaded file name and it will check if that file name exist in the designated directory if yes then it will echo an error and stop the script execution.Now one of my friend suggested me that it is very bad asking the admin to manually rename the picture file and asking them to take care of the file duplication problem. the solution he suggested was to rename the file automatically and then store it in the database and then direct it to directory.I am confused about what combination should i give to the renamed file and also make sure it will remain unique file name to be more precise i would like you to understand my directory structureas i said there will be three pictures files the admin will be uploading namely\[quote\] a) Title Picture b) Brief Picture c) Detail Picture\[/quote\]and all the three picture files will be moved to the different respective directory, like title picture goes to title directory and so on. i am using to script below currently just to move and store the file name with path using varchar in the database. \[code\]$ns_pic_title_loc= $_FILES["ns_pic_title"]["tmp_name"];$ns_pic_title_name = $_FILES["ns_pic_title"]["name"];move_uploaded_file($ns_pic_title_loc, $ns_title_target.$ns_pic_title_name) or die(mysql_error());\[/code\]that is just the sample code i havent included the validation function which i am using. i was thinking like i want to rename all the files likea) In title directory the file should be stored as.title_1.jpgtitle_2.jpgtitle_3.jpgtitle_4.jpgand so onand the same way to rest of the pictures. how do i do that? what function do i use to achieve my target. and if this is not the good way to rename the file i would appreciate any suggestion followed to rename the file.thanks in advance
 
Back
Top