473,383 Members | 1,880 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Date and Filetime of a HTTP-File

Hello,

I want to transfer a file from a http-server to another.
Well, that goes fine like this:

$upload = ftp_put($conn_id, "$destination_file", "$source_file",
FTP_BINARY);

But I want - before the transfer - to know wether the $source_file exists.
More, I want to know and keep its original filetime.

I tried with file_exists. Don't work. So don't work fileatime etc. either.

How ?

TIA

Hanjo
--
Software & Seminar-Kontor Hans-Joachim Grüßner
Glasholz
D-24369 Waabs
http://www.gruessner.de
Sep 28 '05 #1
3 3249
Hanjo Grüßner schrieb:

But I want - before the transfer - to know wether the $source_file exists.
More, I want to know and keep its original filetime. Same answer as in de.comp.lang.php.misc :-)
TRy to open the file
$fp = fopen("path/filename","r")
I think it is not possible to keep the date, because the file is created
in the file system therfor it becomes the current date.
I tried with file_exists. Don't work. So don't work fileatime etc. either.

This function works only lacal not on remote systems.

-Kirsten
Sep 28 '05 #2
> But I want - before the transfer - to know wether the $source_file
exists.

try fopen function.
More, I want to know and keep its original filetime.


do you mean date/time on last modification ?
do you want it locally or remotely ?

--
alex
Sep 28 '05 #3
Am Wed, 28 Sep 2005 16:08:30 +0200 schrieb alex <al**@nospam.org>:


try fopen function.
More, I want to know and keep its original filetime.


do you mean date/time on last modification ?
do you want it locally or remotely ?


Hello,

and thanks.
I already solved it.
As you proposed, the existence of the file by fopen,
to get the original filetime of the file I had to access the HTTP-HEAD.

I succeeded so:

function filemtime_remote($uri)
{
$uri = parse_url($uri);
$handle = @fsockopen($uri['host'],80);
if(!$handle)
return 0;

fputs($handle,"GET $uri[path] HTTP/1.1\r\nHost: $uri[host]\r\n\r\n");
$result = 0;
while(!feof($handle))
{
$line = fgets($handle,1024);
if(!trim($line))
break;

$col = strpos($line,':');
if($col !== false)
{
$header = trim(substr($line,0,$col));
$value = trim(substr($line,$col+1));
if(strtolower($header) == 'last-modified')
{
$result = strtotime($value);
break;
}
}
}
fclose($handle);
return $result;
}

I returns the original filetime as an Unix-timestamp.

Greetings from the baltic sea

Hanjo

--
Software & Seminar-Kontor Hans-Joachim Grüßner
Glasholz
D-24369 Waabs
http://www.gruessner.de
Sep 28 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Bryan Yeo | last post by:
Trying to get the user password expire date from AD, but there is no such field. What I could get is the PasswordLastChanged property. Is there anyway I could calculate the date or something? ...
1
by: aunthas | last post by:
I want to play sound using winapi, so I wrote these lines of code:- ------------------------------------------------------------------------------------------------------------------- using...
3
by: yxq | last post by:
Hello, The XP Desktop clean wizard can get the last access time of desktop shortcut, i found that the info come from ...
2
by: yxq | last post by:
There are 8 bytes binary value stored date and time in Registry. 84 8B D7 DF 8B 28 C5 01 I want to convert the binary value to date using VB.NET. Dim a As FILETIME a.dwHighDateTime = 29698187...
5
by: mbyrd1332 | last post by:
Just wondering if any of you knew of a way to trap the <!-- #BeginDate format:Am1 -->April 4, 2006<!-- #EndDate --> (Dreamweaver's Auto-Update-on-Save Date Code) into a PHP variable and still have...
1
by: Sneil | last post by:
I know, general answer for my question is: long hFT2 = (((long) ft.dwHighDateTime) << 32) + ft.dwLowDateTime; DateTime dte = DateTime.FromFileTimeUtc(hFT2); where dwHighDateTime/dwLowDateTime...
14
by: msavazzi | last post by:
Hi, it should be simple, put FILETIME in a Long conver it in date using the DateTime.FromFileTimeUtc The help even says: Converts the specified Windows file time to an equivalent UTC time. ...
2
by: Bob Altman | last post by:
Hi all, I need to simulate current date and time and provide integer values for the current year, month, day, hour, minute, second, and millisec. I need to do this in unmanaged C++. My first...
5
by: rob.zumwalt | last post by:
Hi All, I have written a wrapper around a C++ class to make it available to C#, built into a dll. This has gone just fine, but one of the methods in the C++ class takes a FILETIME pointer as an...
2
by: nabil035 | last post by:
hi, wel I have these vars: double day,month,year,hour,minute,second,millisecond; I want to convert this data to a filetime structure, I don't want of course to convert them manually ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.