Is it a good practice to keep an uploaded file with it's tmp_name? Check the following example:
$short_tmp_name = substr($_FILES['tmp_name'], -6)
move_uploaded_file($_FILES['file'], "$uploads_dir/$short_tmp_name");
When handling file uploading like in above example:
EDIT:
I've clarified the question(modified the code example).
there is no issue as such, but to be on safer side and handle error, do something like shown below. NOTE : Just a sample code, add more error/other checks and handling based on your need
$error = '';
if ($_FILES["file"]["size"] == 0) {
$error = 'Uploading failed';
}
else if ($_FILES["file"]["size"] > MAX_UPLOAD_FILE_SIZE) {
$error = 'File size exceeds ' . MAX_UPLOAD_FILE_SIZE_MB;
}
else if ($_FILES["file"]["error"] > 0) {
$error = 'Error while uploading';
}
if(!$error) {
$file_name = $_FILES["file"]["name"];
if (file_exists(DESTINATION . $file_name)) {
$path_parts = pathinfo($dstFile . $file_name);
$file_name = $path_parts['filename'] . '-' . time() . '.' . $path_parts['extension'];
}
$dstFile = DESTINATION . $file_name;
if (move_uploaded_file($_FILES["file"]["tmp_name"],$dstFile)) {
//its done
}
else {
$error = 'Unexpected system error';
}
}