Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Create a random filename

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Create a random filename

Postby pugs421 » Mon Jul 07, 2003 10:04 am

Is there a function to create a unique random filename. Right now when a user uploads a file I just name it to the time. But that cant be good if two users upload something at the same time, right?
pugs421
New php-forum User
New php-forum User
 
Posts: 31
Joined: Sat Jun 28, 2003 9:09 pm

Postby Redcircle » Mon Jul 07, 2003 10:19 am

You could use a combination of thier user_id and time.
User avatar
Redcircle
Moderator
Moderator
 
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA

Postby pugs421 » Mon Jul 07, 2003 10:26 am

actually an admin sets up the new members so a user_id is not established until after the info is submitted.
pugs421
New php-forum User
New php-forum User
 
Posts: 31
Joined: Sat Jun 28, 2003 9:09 pm

Postby Joel » Mon Jul 07, 2003 10:54 pm

Code: Select all
$rand = round(time() * rand(0, 9) / 1000);
$filename = "$rand.jpg";
Joel
New php-forum User
New php-forum User
 
Posts: 193
Joined: Sat Mar 29, 2003 11:57 pm
Location: Auckland, New Zealand


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot] and 5 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.