Create a random filename

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

pugs421
New php-forum User
New php-forum User
Posts: 31
Joined: Sat Jun 28, 2003 9:09 pm

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?

User avatar
Redcircle
Moderator
Moderator
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA
Contact:

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

You could use a combination of thier user_id and time.

pugs421
New php-forum User
New php-forum User
Posts: 31
Joined: Sat Jun 28, 2003 9:09 pm

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.

Joel
New php-forum User
New php-forum User
Posts: 193
Joined: Sat Mar 29, 2003 11:57 pm
Location: Auckland, New Zealand
Contact:

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

Code: Select all

$rand = round(time() * rand(0, 9) / 1000);
$filename = "$rand.jpg";


Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 1 guest