Note Submitter: Jared
----
If you want a unique filenames to prevent overwritting is to use sha1_file().
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
if (isset($_FILES['pic']))
{
$file = $_FILES['pic'];
if ($file['error'] == UPLOAD_ERR_OK)
{
$name = sha1_file($file['tmp_name']);
$pathInfo = pathinfo($file['name']);
if (isset($pathInfo['extension']))
$name .= '.'.$pathInfo['extension'];
if (move_uploaded_file($file['tmp_name'], $uploaddir.$name))
{
// ..ok..
}
else
{
// ..failed..
}
}
}
}
?>
Its unlikely 2 files will ever get the same filename, unless they are the same.
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.