Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP - Get timestamp for uploaded file transfer completion

Tags:

date

file

php

time

ftp

Is it possible to get the date that a file was uploaded to FTP? Not created.

Its use will be in a system where I upload files for a client to view which will appear on a dynamic page and need to be timestamped with when they were last changed.

I basically need to get the time that the file had finished transferring onto FTP - via an FTP client, uploaded by me.

like image 977
Marty Avatar asked May 16 '11 04:05

Marty


1 Answers

Use PHP's stat() function. It returns every data that you'll need to know.

http://php.net/manual/en/function.stat.php

<?php
/* Get file stat */
$stat = stat('C:\php\php.exe');

/*
 * Print file access time, this is the same 
 * as calling fileatime()
 */
echo 'Access time: ' . $stat['atime'];

/*
 * Print file modification time, this is the 
 * same as calling filemtime()
 */
echo 'Modification time: ' . $stat['mtime'];

/* Print the device number */
echo 'Device number: ' . $stat['dev'];
?>

I think that in your case "file modification time" is the answer.

like image 96
Tomasz Kowalczyk Avatar answered Oct 07 '22 01:10

Tomasz Kowalczyk