I have a html form with file input named image that points to a php file with this code:
$date = date( "Y_m_d_H_i_s_u" );
function upload() {
$info = pathinfo($_FILES['image']['name']);
$target = "uploads/" . $date . $info['extension'];
if(move_uploaded_file($_FILES['image']['tmp_name'], $target)) {
return true;
} else{
return false;
}
}
I want the filename to have the time in it instead of the original filename. I can’t figure out why this won’t work! All the uploaded files are named the extension. Somehow the date won’t work.
Your scope is wrong for
$date.You will want to either pass
$dateto your function or make it a global varibleor