Any better way than time()

Soldato
Joined
2 May 2004
Posts
19,950
Hi,

Currently, infront of the name of files uploaded onto my site I put a time stamp (time()). Sometimes the time stamp is up to 10 digits out compared to the link meaning sometimes they don't work and I have to change the name of the file to make it work.

Is there anything better than time() I can use that will avoid this problem please?

[Edit]
Also, I put a time stamp in to avoid people uploading a file named the same as another file, as this would overwrite the other file.

Thanks
Craig.
 
True, but most of the time it works, just sometimes the link is a few out for some reason. :(
I'll check out rand and uniqeid and see if I like them :)

Thanks
Craig
 
OK, I noticed that on the upload part i was doing time() . before the filename and then on the SQL part I was doing time() . before the filename meaning sometimes they might have been slightly out... which they were. So instead I did this:

$time = time();

And then instead of using time() before the filename I used $time :)

It hasn't gone wrong since :)

Thanks for the help everyone
Craig
 
Was thinking that, that md5 uniqid time thingy is pretty good but it's a little long, makes the filename real long :(

Could I use rand() on it's own? Would there be any down sides to that?

Thanks
Craig.
 
Back
Top Bottom