|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
rename the imagefile to the highest avilable number in DIR
Hello
I´m programming a image gallery, the uploaded pics should all be uploaded to the same folder, wither they are in the same image gallery.....i´m use mysql to have to numbers of the pics sorted.......anyway!!! Say that there where images like 331.jpg 332.jpg 333.jpg in the folder, i want to upload the new pic to this folder and rename to to the highest number of them all....exzedra exzedra... im this case it would be renamed to 334.jpg Can anyone help me!!! |
|
#2
|
|||
|
|||
|
so for each file thats uploaded you want to increment the file name?
Because your using a database to store details about it. It would be easier if you store the name of the file in a database, So we have the database with the name, 334.gif..etc 334.gif is the last file added you firstly need to get the last number in this case 334 $query = mysql_query("SELECT file_name FROM images ORDER BY id DESC") this should give you the last entry added then you have something like this $count = mysql_result($query, 0, 0); $count = explode(".", $count); so now $count[0] holds our number then we increment it $number = $count[0] + 1, so now you have the next number, in which y |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > rename the imagefile to the highest avilable number in DIR |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|