PHP newbie here..
I am trying to create an if statement that will change the name of
to something unique if $_FILES["file"]["name"]
comes back true. file_exists()
My code is given below.. I tried to use
but I'm not 100% sure as to how to implement it using PHP. tempnam()
if (file_exists("upload/" . $_FILES["file"]["name"]))
{
$_FILES["file"]["name"] = "image/tempnam('',newsFeed)";//this is my problem
$dialog = $_FILES["file"]["name"] . " already exists. ";
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"]);
}
Is there a better way to do this because right now I'm just getting a php error:
Warning: move_uploaded_file(upload/image/tempnam('',newsFeed)) [function.move-uploaded-file]: failed to open stream: No such file or directory
The directory does exist because the upload form works with files that don't have the same name.
Any sort of help or guidance would be appreciated!