I do a lot of work with files obtained via ftp. I have a lot of problems with the files being in the wrong mode and when they are uploaded back to the server, the site fails because the file isn't formatted correctly. It gives the Header Already Sent message, due to extra spaces at the end of the file. Another problem this causes is the introduction of spaces between the lines. A file might start off with
but ends up with
I've seen some files with 10 empty lines between each line.
I've searched all over and found a few programs that will convert the files to dos mode, and that helps a little. But the conversion can only be one at a time and I've had instances of close to 100 files that had to be edited, so that really isn't a solution.
I've tried setting my ftp program to passive and non-passive mode, and have used other ftp programs. The problem isn't consistent but will eventually occur no matter what I try. I talked to the authors of one of the ftp programs and he said the ftp programs couldn't cause that. That it was the server that wasn't writing the file in the correct way.
So I'm wondering if anyone knows of a fix for this, or at least a way to quickly convert the files. From what I've seen on the web, it is a common problem but no one seems to have a solution. Does anyone have any suggestions?
I had found other posts on the web regarding the cause of the problem, although the one you provided explains it better than the ones I found. But I was hoping others had experienced it and had a way around it. The servers I work on are almost always Linux but a few are Windows. Others are uploading to the servers so I'm sure it is probably their editors causing it. I have asked a number of them what they are using and DreamWeaver is the one that causes the most damage, although others have said they use both text and php editors so it doesn't seem to matter.
I was really looking for a way to strip the blank lines and extra spaces at the end of the files and to convert the line feeds to dos mode. Although, on thinking about it, that is probably not something easily done with php since it really should be a stand-alone app.
If I find a solution I will post back here in case anyone else has the same problem. I do appreciate your input and thank you for replying.
I had to wait until one came along since I can't create one that fails myself. The attached file will cause a headers already sent message. If the extra lines at the end are deleted, the message goes away. Also notice all of the extra blank lines in the file.