473,386 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

blank line at beginning of downloaded file

Hi everybody!

Hope someone can help me out with this!

I'm sending a file to a user with the following code:

header( "Content-Type: application/binary");
header( "Content-disposition: attachment; filename=$filename");
header( "Content-Transfer-Encoding: binary" );
passthru( "svnadmin dump ".$svn_repos_loc."/".$name );

(the svnadmin dump command returns a mostly ascii file, but could also
contain some non-ascii parts)

Somehow the file that is saved on the recipients computer gets an
additional blank first line. Off course I can strip this somehow, but
I'm interested in an explanation of this behavior and I would like a
more appropriate solution!

Thanks & regards,
Marijn
Jul 17 '05 #1
8 7809
Following on from m. verkerk's message. . .
Hi everybody!

Hope someone can help me out with this!

I'm sending a file to a user with the following code:

header( "Content-Type: application/binary");
header( "Content-disposition: attachment; filename=$filename");
header( "Content-Transfer-Encoding: binary" );
passthru( "svnadmin dump ".$svn_repos_loc."/".$name );

(the svnadmin dump command returns a mostly ascii file, but could also
contain some non-ascii parts)

Somehow the file that is saved on the recipients computer gets an
additional blank first line. Off course I can strip this somehow, but
I'm interested in an explanation of this behavior and I would like a
more appropriate solution!


CR <> CRLF <> LF problem?
The HTTP protocol (rfc2616) uses new lines /blank lines at the end of a
header and it hasa away of interpreting CR/LF etc.


--
PETER FOX Not the same since the poster business went to the wall
pe******@eminent.demon.co.uk.not.this.bit.no.html
2 Tees Close, Witham, Essex.
Gravity beer in Essex <http://www.eminent.demon.co.uk>
Jul 17 '05 #2
m. verkerk wrote:
Somehow the file that is saved on the recipients computer gets an
additional blank first line. Off course I can strip this somehow, but
I'm interested in an explanation of this behavior and I would like a
more appropriate solution!


Check for extra whitespace before the <? or after the ?> in your PHP
source files. Remember to check any include()s...

-- brion vibber (brion @ pobox.com)
Jul 17 '05 #3
Brion Vibber (br***@pobox.com) wrote:
: m. verkerk wrote:
: > Somehow the file that is saved on the recipients computer gets an
: > additional blank first line. Off course I can strip this somehow, but
: > I'm interested in an explanation of this behavior and I would like a
: > more appropriate solution!

: Check for extra whitespace before the <? or after the ?> in your PHP
: source files. Remember to check any include()s...

Note especially that it may be your editor inserting a final new line at
the very end of the php source file.

The > character in the final ?> must be the very last character in the
file.

On unix type "od -c file" to examine the bytes in the file. The last
bytes will be at the end (right?) so it doesn't matter if the file scrolls
by - you only need to see the last byte.

On windows, when all else fails, the lowly notepad can be used to find and
remove a trailing line break in a text file.

--

This space not for rent.
Jul 17 '05 #4
Malcolm Dew-Jones wrote:
Note especially that it may be your editor inserting a final new line at
the very end of the php source file.

The > character in the final ?> must be the very last character in the
file.


Actually, a single final newline after the ?> is ok. But if you have a
space *and* a final newline, or *two* final newlines, they will be output.

(At least this is the case on Unix; if you have Windows-style CRs in
there, who knows what dreadful things happen...)

-- brion vibber (brion @ pobox.com)
Jul 17 '05 #5
"Malcolm Dew-Jones" <yf***@vtn1.victoria.tc.ca> wrote in message
news:42******@news.victoria.tc.ca...
Brion Vibber (br***@pobox.com) wrote:
: m. verkerk wrote:
: > Somehow the file that is saved on the recipients computer gets an
: > additional blank first line. Off course I can strip this somehow, but
: > I'm interested in an explanation of this behavior and I would like a
: > more appropriate solution!

: Check for extra whitespace before the <? or after the ?> in your PHP
: source files. Remember to check any include()s...

Note especially that it may be your editor inserting a final new line at
the very end of the php source file.

The > character in the final ?> must be the very last character in the
file.


Actually, PHP will swallow one linefeed right after ?> or </script>.
Jul 17 '05 #6
"m. verkerk" <m.*******@erasmusmc.nl> wrote:
Hi everybody!

Hope someone can help me out with this!

I'm sending a file to a user with the following code:

header( "Content-Type: application/binary");


I doubt this is related to your problem, but the RFC1521-approved content
type for binary data is "application/octet-stream". "Application/binary"
is not defined, as far as I know.
--
- Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Jul 17 '05 #7
Thank you all for the help!

After closer examination, this white line seems to be caused by the
application framework I'm using (Prado).

thanks again!

Marijn

m. verkerk wrote:
Hi everybody!

Hope someone can help me out with this!

I'm sending a file to a user with the following code:

header( "Content-Type: application/binary");
header( "Content-disposition: attachment; filename=$filename");
header( "Content-Transfer-Encoding: binary" );
passthru( "svnadmin dump ".$svn_repos_loc."/".$name );

(the svnadmin dump command returns a mostly ascii file, but could also
contain some non-ascii parts)

Somehow the file that is saved on the recipients computer gets an
additional blank first line. Off course I can strip this somehow, but
I'm interested in an explanation of this behavior and I would like a
more appropriate solution!

Thanks & regards,
Marijn

Jul 17 '05 #8
Tim Roberts wrote:
but the RFC1521-approved content type for binary data is
"application/octet-stream".
Yes, arbitrary binary data.
"Application/binary" is not defined, as far as I know.


It isn't defined publicly; that is, it isn't registered
with the IANA. So the subtype should be prefixed with 'x-',
giving 'application/x-binary'.

But as you say, 'octet-stream' is the registered subtype.

--
Jock
Jul 17 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: dan glenn | last post by:
Hi. I'm finding that if I have text entered into a <textarea ...> </textarea> in a form, and that text has leading blank lines (with no spaces or anything else), that when I retrieve the entered...
3
by: yanakal | last post by:
Hi, I'm using isql to query data and output the same to a flat file. The isql has the following command options ' -h-1 -w500 -n -b -s"" '. In the SQL_CODE, the first two lines before the select...
0
by: erucevice | last post by:
I am trying to bcp a text file that is written out of a Java application. The text file has important order information that I need to bcp into a SQL Server 2000 database. The problem is that when...
6
by: EricR | last post by:
I am trying to bcp import a text file into a SQL Server 2000 database. The text file is coming out of a java application where order information is written to the text file. Each record is on it's...
16
by: btopenworld | last post by:
Hi - question from a relative asp novice I have written to text files in the past, but always appending new data to the end of the text file. I now want to add the new data to the beginning of...
2
by: jatindersingh80 | last post by:
Hi , i am reading a text file with token # but somtimes blank lines comes between the line at blank line the code gives exception of no such element the text files contains data after blank lines...
7
by: Joy M | last post by:
Hello, I am modifying an .asp file and I noticed that the top line on the screen is blank. I would like to remove this line, and push everything up to the top of the screen, but I don't know...
4
by: BibhuAshish | last post by:
Hi, I wanted to delete a line from xml file which i did it. But after deletion of that line there is a blank space. Again if i am adding another line by using java that blank line remains as...
4
by: Patrick Nolan | last post by:
I am using javascript to manipulate optgroups in select elements. When the results are displayed in Firefox 2.0 there is an annoying blank line at the top of the multi-line select box. This...
4
by: djaekimaar | last post by:
Hi. First I apologise if there is a better place to post this. Please let me know. I also apologise in advance if this is a really stupid mistake, but now seem to be bashing head against wall. I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.