Jump to content

Php Files?


webgyrl
 Share

Recommended Posts

Just wondering... are PHP files supposed to be uploaded in BINARY or ASCII mode?

 

I have my FTP Extension Map here in Dreamweaver and am updating it... it shows the following

 

PHP ASCII

PHP3 ASCII

PHP4 ASCII

PHP5 ASCII

 

Should these be changed to BINARY?

 

Thanks

Link to comment
Share on other sites

Thanks Robert!

 

That's what I thought, but just wanted to be sure.

 

What would happen if one uploaded a PHP file in BINARY? Would it not show/work?

Link to comment
Share on other sites

Uploading a file in ASCII tells the FTP server to convert the line endings from the format the operating system on your PC uses to the format that the operating system on the server uses.

 

Window systems use a two character LF / CR (line feed + carraige return) line ending.

 

Mac systems use a one character CR line ending character.

 

Linux systems use a one character LF line ending character.

 

If I upload a text file from my Windows PC to my TCH account (which is a Linux server), all of the LF / CR character combinations in my Windows text file will be automatically converted to LF characters when the file is saved on the TCH server, so the server will be able to read the lines in it correctly. (The reverse happens if I download a text file in ASCII mode from the TCH server to my Windows PC.)

 

This can be crucial for some types of text files, because if they have the wrong type of line ending, the server won't be able to read them properly. A multi-line script may be seen as one long line, because the server doesn't see proper line ending on each line.

 

Uploading a file in BINARY tells the FTP server to NOT convert any characters at all, to just store the file as it was uploaded. You want this for files such as .zip or .tar.gz compressed archives (altering bytes within them will corrupt them), and graphic file formats (altering bytes within them will change your image and possibly render it unviewable).

 

Since PHP files are generally text scripts, they should be uploaded and downloaded in ASCII mode so the line ending characters are converted to the correct format. If you upload a PHP script in BINARY mode, the worst that would happen is that you would get a 500 server error because the server mis-reads the file.

Link to comment
Share on other sites

David,

 

Thanks for explaining all that to me. It's nice to know how things work and also why they won't work or what could happen if you mess up!

 

Thanks again.

Link to comment
Share on other sites

David,

 

Another fine explanation.

Still there are circumstances where uploading a php in binary is crucial to get it to work.

As an example (and I think this is one of the reasons webgyrl asks abt this) Ultimate Form Mail which is partially coded through ioncube doesn't work when uploaded in ascii.

 

In that case the files are broken and an error message will result.

 

I don't know the exact details as to why but thre are circumstanced that require a binary upload also for php files ;)

 

Grtx

Link to comment
Share on other sites

David,

 

Another fine explanation.

Still there are circumstances where uploading a php in binary is crucial to get it to work.

As an example (and I think this is one of the reasons webgyrl asks abt this) Ultimate Form Mail which is partially coded through ioncube doesn't work when uploaded in ascii.

 

In that case the files are broken and an error message will result.

 

I don't know the exact details as to why but thre are circumstanced that require a binary upload also for php files ;)

 

Grtx

 

That's exactly why I asked.

 

I did an experiment. I uploaded the UFM files via FTP in BINARY and then I overwrote some of them using DW FTP with the setting set at ASCII.

 

It still works either way.

 

Will I run into problems if I change a PHP file for this script and upload using ASCII?

 

I've already altered the mailit.php, header.php, footer.php, thanks.php, email.tpl.php and the contact.php files and uploaded tehm in ASCII using DW and everything is working perfectly as of now.

 

All the other files were uploaded via FTP in BINARY.

 

Is it strange that it works, or am I asking for trouble?

Link to comment
Share on other sites

That's why I said, "PHP files are generally text scripts." The Ultimate Form Mailer is one of those exceptions. (I know this because I have it installed on my own web site.)

 

If I remember correctly, at least some of the files distributed with UFM are "compiled PHP" - these would be the equivalent of a Windows .exe file and do need to be uploaded in BINARY mode (as the UFM installation instructions indicate); otherwise, the compiled file is corrupted and will give errors when you try to run it.

 

Bottom line: UFM is a special case that requires special handling. ;)

Link to comment
Share on other sites

I've already altered the mailit.php, header.php, footer.php, thanks.php, email.tpl.php and the contact.php files and uploaded tehm in ASCII using DW and everything is working perfectly as of now.

 

All the other files were uploaded via FTP in BINARY.

 

Is it strange that it works, or am I asking for trouble?

If it's working, then you're fine.

 

Will I run into problems if I change a PHP file for this script and upload using ASCII?

No, that exactly what you should do. The files you're editing are plain text files and should be uploaded in ASCII mode.

Link to comment
Share on other sites

Ok David... that is good to know.

 

It's a lot easier for me to be able to tweak design elements and upload via Dreamweaver to check them live right away and then go back and tweak again if necessary.

 

Thanks to all who shared knowledge on this topic.

Link to comment
Share on other sites

I agree abt the speciality ;)

 

As David said I think only clss.ufm.php is encoded and should be uploaded in binary.

Still all the other files can be uploaded in binary also. That will lead to no problems..

 

And last but not least. I am very glad I now know WHY php files should be uploaded in ascii or binary.

Case closed I guess :)

 

Thnx Richard (alias ALTB)

Link to comment
Share on other sites

I use DW to write my code (most of the time). And DW is great at a lot of things. But it's not very good at 1) complex css and 2) ftp

 

Someone else at TCH recommended FileZilla and I love it. I use it exclusively for file upload, editing, etc.

 

If you set it up correctly, it's really not that big of an extra step.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...