Have a read for the docs for file upload : how to handle file uploads
- The uploaded file is located at
$_FILES["fileToUpload"]["tmp_name"][$i]
(Read it carefully, it is tmp_name)
- The name of the file in
$_FILES["fileToUpload"]["name"][$i]
does not contain any path. Useless to basename it.
- You need to move the uploaded file to the location you want with the function
move_uploaded_file
Once you've fixed the path issue, i bet you'll be disapointed : file creation date is a meta data of a file, it's managed by the file system (if it wants to) and as such is not inside the file.
This piece of information is not transferred during file upload. Unless you have files in which there may be meta information (like exif in images), there's no way to get the creation date of original files. By the way, you want Creation date but are using a function called fileMtime, the 'M' stands for Modification time...
For the rest Andreas explained you why date is 1970, as filemtime does not find a file to stat
// __DIR__ is directory of this php file, set accordingly
$target_dir = __DIR__ . '/';
$thumb_target_dir = __DIR__ . '/';
$image_count = count($_FILES["fileToUpload"]["name"]);
for ($i = 0; $i < $image_count; $i++) {
//Setup file names and file types
// Create the path to the location where we want to store the file
$temp_name = $target_dir . $_FILES["fileToUpload"]["name"][$i];
// We need to move the temp file to the location we want :
move_uploaded_file($_FILES["fileToUpload"]["tmp_name"][$i], $temp_name);
$temp_thumb_name = $thumb_target_dir . $_FILES["fileToUpload"]["name"][$i];
$temp_type = pathinfo($temp_name, PATHINFO_EXTENSION);
array_push($target_file, $temp_name); // Create array of file names
array_push($target_file_thumb, $temp_thumb_name); //Create array of thumb path names
array_push($imageFileType, $temp_type); //Create array of fileextensions
// Get the file modif time, but only of the local file.
$fmtime = filemtime($temp_name);
echo "<BR>was last modified: " . date("F d Y H:i:s.", $fmtime);
array_push($file_creation, date("F d Y H:i:s.", $fmtime));
}