Forum Moderators: coopster
if (is_uploaded_file($_FILES['image']['tmp_name'])){
if (move_uploaded_file($_FILES['image']['tmp_name'], "../uploads/{$_FILES['image']['name']}")) {
$problem = FALSE;
echo '<p align="center"><font color="red"><b>The file was uploaded</b></font></p>';
} else {
$problem = TRUE;
echo '<p>The file could not be moved because </p>';
$img_name = 'noimage.jpg' ;
}
$img_name = $_FILES['image']['name'];
} else {
$img_name = 'noimage.jpg';
}
What I would like to know is how I rename a file so it uploads as a different name (security reasons and to stop the scenario of 2 duplicate file names)
Hope someone can help
Steve C
if (move_uploaded_file($_FILES['image']['tmp_name'], "../uploads/{$_FILES['image']['name']}")) {
to:
if (move_uploaded_file($_FILES['image']['tmp_name'], "../uploads/".$newname)) {
after setting $newname to the desired name, of course.
And read: [be2.php.net...]
Normally, you could answer your own question here by reading the manual on move_uploaded_file(), and fortunately I'm not in a carniverous mood today.