savagenoob Posted October 5, 2010 Share Posted October 5, 2010 Whats the easiest way to rename uploaded files to a unique name that would never be duplicated? Link to comment https://forums.phpfreaks.com/topic/215235-unique-name-for-file/ Share on other sites More sharing options...
rwwd Posted October 5, 2010 Share Posted October 5, 2010 I don't think as that would be possible, unless you wrote in a clause to say if this exists, generate another, but personally functions like rand(0,999); and shuffle() could help generate a string:- $arrayOfChars = str_split('0123456789QWERTYUIOPASDFGHJKLZXCVBNM'); shuffle($arrayOfChars); echo $arrayOfChars[rand(0,36)].$arrayOfChars[rand(0,36)].$arrayOfChars[rand(0,36)]; something like that would produce a string with 'jumbled' content that would have countless permutations.. I must stress, this is just for example, it may not work like that; but I think it could ;-p Rw Link to comment https://forums.phpfreaks.com/topic/215235-unique-name-for-file/#findComment-1119406 Share on other sites More sharing options...
litebearer Posted October 5, 2010 Share Posted October 5, 2010 using the date/time as the name - would generaly produce and ordered filename system Link to comment https://forums.phpfreaks.com/topic/215235-unique-name-for-file/#findComment-1119439 Share on other sites More sharing options...
plznty Posted October 6, 2010 Share Posted October 6, 2010 Use a sequence with a very large amounts of permutations available, then check if file exists, if exists from another and loop it. Link to comment https://forums.phpfreaks.com/topic/215235-unique-name-for-file/#findComment-1119530 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.