koramado Posted May 2, 2008 Share Posted May 2, 2008 Hello, I'm creating a script which allows users to upload data contained in a text file, which is then parsed for inclusion in a database. I am trying to find a way to read the last modified value of the file being uploaded so that I can include a timestamp of when the data was created. I have been trying to use the various functions to read the last modified time, but can only get the time after the file is uploaded to the server. I am wondering if it is at all possible to check the last modified time of a remote file being uploaded, so I can use the time the file was originally created and not the uploaded time for timestamping the data. Any insight is appreciated. Joel Quote Link to comment Share on other sites More sharing options...
DarkWater Posted May 2, 2008 Share Posted May 2, 2008 $mod_time = filemtime("test.txt"); echo "test.txt was last modified on "; echo date("D d M Y g:i A", $mod_time); //Sample: Thurs 1 May 2008 7:14 AM Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted May 2, 2008 Share Posted May 2, 2008 Your server, and consequentially PHP, doesn't have access to the remote file until it's uploaded. Your only hope is javascript (or some other client side script...vbscript, etc), and I'm pretty sure it's sandboxed so that what you are asking won't work (I could be wrong though). Quote Link to comment Share on other sites More sharing options...
DarkWater Posted May 2, 2008 Share Posted May 2, 2008 Oh, BEFORE it's uploaded. Woops. You can't do that...at least I don't think you can. Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted May 2, 2008 Share Posted May 2, 2008 anyone know if the uploaded file retains it's mod date after the upload? just curious... Quote Link to comment Share on other sites More sharing options...
koramado Posted May 2, 2008 Author Share Posted May 2, 2008 No, BlueSkyIS, the uploaded file has a new mod date relative to the time it is uploaded to the server. I've been thinking about this all day and had started to figure that it just wasn't possible. I just wanted to be certain i wasn't missing something. Thanks for the suggestions. I suppose I might try looking for a small javascript solution or else I can just prompt the user for the file creation information when they select the file to upload. Quote Link to comment Share on other sites More sharing options...
koramado Posted May 3, 2008 Author Share Posted May 3, 2008 I kept digging around and have started wondering if PHP/CURL could be used to read the mod time of a remote file. I see the function curl_getinfo() and settings like CURLOPT_FILETIME, but I don't have any experience using them. Can someone tell me if CURL only works on on server hosted files? Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted May 4, 2008 Share Posted May 4, 2008 cURL is basically a command line web client. It has some other functionality, but unless the client files are actually files on another web server, then it won't work. Quote Link to comment Share on other sites More sharing options...
koramado Posted May 4, 2008 Author Share Posted May 4, 2008 Alright then. I guess I'll have to work it out another way. Thanks for all of the input. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.