To store uploaded files by users on remote server inside disk folder I change the name of file to
$filename = '/tmp/foo.txt'; $newName = sha1_file($filename); // 40 characters //or I can do $newName = uniqid($filename) // 13 characters
Which is a more robust method for new name that is not likely to fail ?? Thanks.
A better solution is to use
tempnam(). Either one is guaranteed to create an unused file that won't collide and can't be "intercepted" by rogue processes changing permissions on you.
tmpfile() automatically deletes the file when it's closed, whereas
tempnam() keeps it around
The content is written by members of the stackoverflow.com community.
It is licensed under cc-wiki