Determining FTP_ASCII or FTP_BINARY

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
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Determining FTP_ASCII or FTP_BINARY

Post by kendall »

i am using ftp_put to upload files to the server. However How do you determine what mode to use for files like word, excel and pdf? as i no images would be binary.

Whats the best way to check if the file is ASCII or BINARY?
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

Re: Determining FTP_ASCII or FTP_BINARY

Post by yacahuma »

do the file have extensions?
I will use that to start with
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Determining FTP_ASCII or FTP_BINARY

Post by califdon »

kendall wrote:i am using ftp_put to upload files to the server. However How do you determine what mode to use for files like word, excel and pdf? as i no images would be binary.

Whats the best way to check if the file is ASCII or BINARY?
For uploading unknown files, I think I'd just always make it binary. File extensions can be misleading. I don't know of any reliable way to determine in advance whether a remote file is ASCII or not.
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Re: Determining FTP_ASCII or FTP_BINARY

Post by kendall »

hmmm....thanks calif...i was running a preg_match on file ext....will using binary make text based files readable? as these files maye need to be "included" or fread
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Determining FTP_ASCII or FTP_BINARY

Post by califdon »

To the best of my knowledge, ftp binary mode will read any file. I *think* ASCII mode is just a little more efficient if the file contains nothing but ASCII characters. Here's a pertinent thread on another forum: http://www.velocityreviews.com/forums/t ... inary.html
Post Reply