View Full Version : making a random and unique file name???

04-06-2003, 06:06 PM
im making an uploadingsystem for my staff and i was wondering how you ould make an image file have a unique number name alos so that it has that same name in a databasa...

im not sure if i made that clear enough if not just ask ill give more detail.

04-06-2003, 06:43 PM
If your database table has a unique index then you can name the image using that index.... eg

again assuming there is an autoindexed field in your table

$res=mysql_query("INSERT INTO $table ($fields)VALUES($values)");

now $im_name contains the 'id' of your insert and you can name the image with that.

else look at http://www.php.net/uniqid which will create a unique ID for you.