Trouble renaming... (SOLVED)
Posted: Sat Feb 25, 2012 3:47 pm
Hi all,
having a little trouble with an "upload and rename" script.
Code here - any help much appreciated.
Monty
having a little trouble with an "upload and rename" script.
Code here - any help much appreciated.
Monty
Code: Select all
<?php
$ext = pathinfo($filename, PATHINFO_EXTENSION);
// strip the file extension
$file_without_ext = substr($filename, 0, -4);
// set random newname (timestamp)
$randFilename = uniqid('img_');
$newFilename = $randFilename.".".$ext;
if ($_FILES['Filedata']['name']) {
move_uploaded_file($_FILES['Filedata']['tmp_name'], '../news/images/' . basename($_FILES['Filedata']['name'],$newFilename));
}
?>