Need programming help re: timestamps (perl cgi and html)

imported_Tomato

Diamond Member
Sep 11, 2002
7,608
0
0
I am using perl cgi and html to upload a file and then run a number of perl tests. I want to cache the tests by the timestamps of the uploaded file. The files to be uploaded will reside on windows machines, how can I check their time stamps?

I tried using perl's stat function but it only worked on my local copy and gave me the local timestamps and not the windows file's timestamps.

I am really stuck.

Any help would be greatly appreciated, thanks!
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
How are you uploading? If the server is accepting the upload with script code, you could have the code return the timestamp of the saved file in its response.

Another way is to have a separate CGI page (in perl, ASP, etc) on the server that you pass a file name to and in looks up the stats for that name.
"/mylookup.asp?filename=myfile.txt"
 

imported_Tomato

Diamond Member
Sep 11, 2002
7,608
0
0
I've got a html form that calls a perl script that uses cgi. and uses the function
upload.

from that i can get the contents of the file, but if i run stat on the file handle that upload returns, i get the timestamps for the local copy.

how can i get the original copy. i didn't understand what you said about using another page. can you explain how i would do that using another perl page? or perl function?

thanks.

 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
Oh, you want the client timestamp, I read your first post as client-side code needing the _server_ timestamp. I've done too much client-side programming lately :)

I don't think you can get the client timestamp -- the multipart encoding for an < input type=FILE > includes a name but no other info.

Unless you find a security hole, script code running on the client should not be able to read any information about the user's file system, so you can't set a hidden variable using script code.

If you have any control over how the uploaded file's contents are created (before it is uploaded), you could write the time of day inside the file when you create or update it.
 

notfred

Lifer
Feb 12, 2001
38,241
4
0
You can only get data about files on the server from the server. The server has no idea what time the files on the client's machine were modified, it can only tell when the files on the server were modified.
 

imported_Tomato

Diamond Member
Sep 11, 2002
7,608
0
0
Ok...so how would I do it? I would think this is a common problem:

i want to upload a file and run a test only if it is a newer version. if its an older version i just want to send the cashed results.

how do i get around the problem? also the client files will be in windows and the scripts are in unix.

thanks

 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
I can think of two ways with a browser:

You can embed a timestamp inside the file as data, extract and store this on the server when doing tests

You can have the user manually type in a date/time when uploading

A third way would be to use a custom C++ or VB client program on the desktop to do the uploading instead of an HTML form in the browser. A browser window has no access to the desktop file system but an application does.

The application would connect to the server as a browser does (in VB using the Internet Transfer Control, in C++ using WinInet, or a third-party library for either). The key difference is that the application can send the < input type=FILE > file but can also read the file system and send other variables (like filling out extra <input type=text name=date > <input type=text name=time > fields manually)