I want to change the name of the uploaded file, to the current time by using time()
but i cant seem to figger out where to insert the new time name ?
can some one try look at this ?
<?php
if (!empty($_FILES)) {
$newName = time(); <-- Should be the new temp name, insted of the uploaded one.
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_GET['folder'] . '/';
$targetFile = str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];
move_uploaded_file($tempFile,$targetFile);
}
echo '1';
?>
$_FILES['Filedata']['name']
has your filename, you can replace that but first you need to get the file's extension if it's not the same all the time.
$p = pathinfo($_FILES['Filedata']['name']);
$newName = time() . "." . $p['extension'];
$targetFile = str_replace('//','/',$targetPath) . $newName;