...

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



stoodder
04-06-2003, 05: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.

firepages
04-06-2003, 05: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)");
$im_name=mysql_insert_id();
?>



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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum