md5_file via ftp connection

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
SidewinderX
Forum Contributor
Posts: 407
Joined: Fri Jul 16, 2004 9:04 pm
Location: NY

md5_file via ftp connection

Post by SidewinderX »

I need to download a file using the ftp functions. However, I need to verify the files integrity. Is there a way, when I connect to the remote server, I can generate an md5 hash of the file (before the transfer so I can compare it to another md5 hash after the transfer)?
User avatar
William
Forum Contributor
Posts: 332
Joined: Sat Oct 25, 2003 4:03 am
Location: New York City

Re: md5_file via ftp connection

Post by William »

Unless the FTP server allows this you're going to have to download it, check the md5, and then decide if you want to keep it or not.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: md5_file via ftp connection

Post by John Cartwright »

I think normal FTP clients compare the last modified timestamp and the filesize.
User avatar
panic!
Forum Regular
Posts: 516
Joined: Mon Jul 31, 2006 7:59 am
Location: Brighton, UK

Re: md5_file via ftp connection

Post by panic! »

Off topic but

John, I reckon your signature could be:

Code: Select all

 
 
if ($toBe || !$toBe) echo 'That is the question';
 
 
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: md5_file via ftp connection

Post by John Cartwright »

//continues offtopic
John, I reckon your signature could be:
I guess it depends how you read it out in your mind. I'm on the fence with this one! :)
crazycoders
Forum Contributor
Posts: 260
Joined: Tue Oct 28, 2008 7:48 am
Location: Montreal, Qc, Canada

Re: md5_file via ftp connection

Post by crazycoders »

I don't know of any FTP commands from the standard FTP RFC file that talks about generating a MD5sum of a file on the fly. This is usually done by the submitter of the file, he uploads the file in the same directory of the file he submitted and then you as a user have to download both the original file and .md5 file and compare the CAT(*.md5) to md5sum() of the file you downloaded.
Post Reply