Welcome to WebmasterWorld Guest from 54.162.166.214

Forum Moderators: incrediBILL

Message Too Old, No Replies

Uploading html file loses formatting

     
4:01 am on Jan 4, 2012 (gmt 0)

Preferred Member

10+ Year Member

joined:June 19, 2006
posts: 476
votes: 0


Why does this happen sometimes when I upload a file and later go to look at it, it has lost its formatting. meaning, its seems to be all one line. instead of structured?

For example

<html>
<head></head>
<body>
</body>
<html>

Becomes

<html><head></head><body></body><html>
4:59 am on Jan 4, 2012 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:14246
votes: 550


Your browser's View Source function is using a different line-break format than your editor, so the breaks aren't recognized. For an exact explanation we would need to know what OS you're on, what editor, what form of line ending it uses, what ftp program you use to upload and what its settings are ... and possibly a few other things.

Or did you mean that when you upload a file and later download the same file, the carriage returns are gone with the wind?

Raise your hand if you saw the topic title and thought the answer would involve relative links and CSS :)
5:11 am on Jan 4, 2012 (gmt 0)

Preferred Member

10+ Year Member

joined:June 19, 2006
posts: 476
votes: 0


when you upload a file and later download the same file, the carriage returns are gone with the wind


using notepad++ and winscp
5:51 am on Jan 4, 2012 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:14246
votes: 550


If you View Source while the file is online, are the line breaks still there? That narrows it down.

Start by checking the settings in your ftp program. A quick look at Fetch, for comparison, tells me that there's a Preference setting under Downloads for line-ending format. In Windows, you need to use CRLF or \r\n. It will probably just say "Windows or DOS format" as opposed to "Unix format". There are even some special line-break markers within unicode, but I doubt those are your problem.
6:03 am on Jan 4, 2012 (gmt 0)

Preferred Member

10+ Year Member

joined:June 19, 2006
posts: 476
votes: 0


it just seems to happen randomly with 1 file out of a batch
9:41 am on June 5, 2012 (gmt 0)

New User

5+ Year Member

joined:June 5, 2012
posts: 8
votes: 0


I am having exactly the same issue uploading to godaddy shared linux hosting. Using Notepad++ and WinSCP also. Anyone have any ideas?
6:25 pm on June 5, 2012 (gmt 0)

Senior Member

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:July 3, 2002
posts:18903
votes: 0


@lucy ::raises hand::

I'll shut up now.
9:30 pm on June 5, 2012 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:14246
votes: 550


Huh. I thought Forums threads auto-locked after a month or two. Did someone change something?

Do you mean that the file doesn't look right when viewed in the browser, or only that View Source has become illegible? A lot of people don't even care what the source code looks like*, because visible line breaks in html don't have anything to do with line breaks in the source. That is,

<p><br><br><br></p>

looks the same** to your user as
<p>
<br>
<br>
<br>
</p>


* I do. My javascript includes \n in its print output. If I ever get brave and start messing with php, it will do the same.
** Most of the time. There's an exception, but let's not go there. I think it only applied in elderly browsers anyway.
9:45 pm on June 5, 2012 (gmt 0)

Preferred Member

10+ Year Member

joined:June 19, 2006
posts: 476
votes: 0


Its only when I download the file again to edit with notepad++. Im not looking at it with the browser. I suspect it has something to do with file permissions but not sure why some php files would get different permissions that others? Could it be using a networked PC if you create the file from a different machine or directly on that machine. I could see how the PC would see that as different users and possibly assign different permissions to the file? But this gets messed up when uploading it?
9:49 pm on June 5, 2012 (gmt 0)

Senior Member

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:July 3, 2002
posts:18903
votes: 0


Upload the file to a linux server and your FTP client might correct the line endings. If you download the file again and it doesn't change them back, you'll see what you just described.
2:26 pm on June 6, 2012 (gmt 0)

New User

5+ Year Member

joined:June 5, 2012
posts: 8
votes: 0


This seems to be default behavior of WinSCP. I do not know why it has just started doing this, but the solution is simply to change your transfer mode to 'Binary' if you want the file to be uploaded exactly as-is. See the discussion on WinSCP forums here:
[winscp.net...]