Ok so I have been trying to get this to work and I dont see any errors but my syntax checker swears there is one on line 14. Can anyone help me out with this?
<?php
// Define a destination
$targetFolder = '***********'; // Relative to the root
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$tempFileExploded = explode($tempFile, ".");
//PROBLEM LINE
$tempFile = $tempFileExploded[0] . date('U') . $tempFileExploded[1];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
$targetFile = rtrim($targetPath,'/') . '/' . $_FILES['Filedata']['name'];
//mkdir(str_replace('//','/',$targetPath), 0777, true);
// Validate the file type
$fileTypes = array('jpg','jpeg','gif','png'); // File extensions
$fileParts = pathinfo($_FILES['Filedata']['name']);
if (in_array($fileParts['extension'],$fileTypes)) {
move_uploaded_file($tempFile,$targetFile);
echo '1';
} else {
echo 'Invalid file type.';
}
}
//$targerfile is the file name
?>
The error im getting:
Parse error: syntax error, unexpected T_STRING in CODE on line 14
Errors parsing CODE
When you explode with dot. you need to extension with dot. so dot is missing in your code
$tempFile = $tempFileExploded[0] . date(‘U’) .”.”. $tempFileExploded[1];