Author Topic: Questions For The More Programming Inclined  (Read 2137 times)

Offline CK9

  • Administrator
  • Hero Member
  • *****
  • Posts: 6226
    • http://www.outpost2.net/~ck9
Questions For The More Programming Inclined
« on: September 13, 2007, 05:43:54 PM »
Okay, so I was thinking of doing a large ammount of work for my site (have many pages ready, got a better navigation system in the works (based soley on the one for the outpost-universe main page, might end up using a javascript nav system instead), and have organization lined up for re-working).  Now I'm thinking of a guest book.  Yeah, I know some of you will probably say, "what's the point?"  Sometimes it's just nice to know what people think of your site.

Anyway, I found something in PHP here that sounds simple enough for me to use, but I don't quite understand the instructions:

Quote
Step 3:. Upload index.php (guestbook script) and gbook.dat (data file) to a directory in ASCII mode
....

Step 4: Upload all of the images (*.gif) to the same directory in BINARY mode.

I never knew it was possible to change the mode of the uplad to a specific type, so I don't know how to do it.  Help please?  Some info that might be needed to answer:

I'm using SmartFTP to upload (though, I've been thinking of switching to CoreFTP as it's 100% free for full software use).
I'm on a LAN with DSL and behind a router
so far, all uploads go off without a hitch
« Last Edit: September 13, 2007, 05:44:18 PM by CK9 »
CK9 in outpost
Iamck in runescape (yes, I still play...sometimes...)
srentiln in minecraft (I like legos, and I like computer games...it was only a matter of time...) and youtube...
xdarkinsidex on deviantart

yup, I have too many screen names

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Questions For The More Programming Inclined
« Reply #1 on: September 14, 2007, 06:53:52 PM »
It's usually not much of an issue, but sometimes it can be a problem you need to be aware of. Most decent clients seems to pick a reasonable setting by default.

The problem is mostly the diffence in the end of line (EOL) charcter between Unix and Windows. (Or other systems). On Unix, I believe it's only charcter 10 (Line Feed), but on Windows, and EOL is two characters 13, 10 (Carriage Return, and Line Feed).

The setting is basically so it can translate the end of line charcter between the two systems during transfer. It's often not a big problem with text files, since many utilities now support either way to end a line without major issues. However, a lot of text editors will still display funny results. On Unit, with a Windows text file, you'll see a lot of "^M" at line breaks, which is the other character which some Unix editors don't know what to do with. On Windows with a Unix file, you might get everything all on one line as it can't find a full EOL, and so keeps going on the same line.


But like I said, a lot of programs will be able to handle both. Some won't though. It's usually fairly safe to transfer a text file in any mode. Even if you get funny output, it's a simple matter to run the file through an automated converter to fix it. (I think many Unix systems have something called dos2unix, and unix2dos, or maybe just d2u, and u2d. They do seem to be overly fond of excessive abbreviations).


The problem is a lot more serious for binary files though. If you send a binary file through text mode, then it can convert the bytes it preceives as EOL characters, and corrupt the file. Binary mode is basically just a direct byte copy without conversion, so it won't corrupt anything or change anything it's not supposed to. (It won't convert your text files for you). If in doubt, binary is the way to go, and seems to be the default of most modern FTP cilents. Some of them will look at the first few bytes of a file though to see if it's ASCII text, and use ASCII mode on you automatically. This can be a problem if you have a binary file that starts with ASCII text, causing some clients to use the wrong mode and corrupt your file.