473,812 Members | 2,795 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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=$filen ame");
header( "Content-Transfer-Encoding: binary" );
passthru( "svnadmin dump ".$svn_repos_lo c."/".$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 7956
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=$filen ame");
header( "Content-Transfer-Encoding: binary" );
passthru( "svnadmin dump ".$svn_repos_lo c."/".$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******@eminen t.demon.co.uk.n ot.this.bit.no. html
2 Tees Close, Witham, Essex.
Gravity beer in Essex <http://www.eminent.dem on.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.co m) 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.vic toria.tc.ca> wrote in message
news:42******@n ews.victoria.tc .ca...
Brion Vibber (br***@pobox.co m) 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.*******@eras musmc.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 "applicatio n/octet-stream". "Applicatio n/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=$filen ame");
header( "Content-Transfer-Encoding: binary" );
passthru( "svnadmin dump ".$svn_repos_lo c."/".$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
"applicatio n/octet-stream".
Yes, arbitrary binary data.
"Applicatio n/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
3292
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 text, I lose the leading blank line. Each time it goes through a post any top-leading blank line is lost. Only one- if I have several blank lines in a row at the top, only the first is lost. (If the top blank line has a single space, it's handled...
3
8598
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 statement are use dbname set nocount on go When I run this, an additional blank line is put into the output file. Actually, there are two lines after the last result set in the output file. This file is being fed into another system and the...
0
2582
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 records are written out by the Java application the last item in each record has a new line character attached to it so that a new line is started for the next record. BCP gives me an error and doesn't import anything if there is this blank line...
6
10000
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 own row, so the last item in each record has a new line character at the end of it to create the next row. This works well in creating the file however bcp does not like to import this text file with the extra blank line at the end. If I change...
16
2996
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 the file. The text file would be a record of orders placed through a web form. The text file would merely be a record of the orders but it needs to be in descending date order - each new record added to the beginning.
2
26748
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 jatinder
7
5873
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 what is causing it to appear. Does any one have any ideas of what to look for? The code has <table><tr><tdtags. There are no <formand no <p>. I hope I have given you enough information, and thank you for your help.
4
25956
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 usual. My xml file is ::::::: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <config> <employee id = "1" name = "aa" /> <employee id = "2" name = "bb" />
4
5371
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 doesn't happen with IE7. There's a little program below which illustrates the problem. I create two multi-line select boxes. The first one has an optgroup and an option specified in the HTML. That one displays with "opt1" as the first line. The...
4
4979
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 have some code that is creating an xml doc $dom = new DOMDocument(); $xmlDoc = $dom->appendChild($dom->createElement('root')); etc.
0
9607
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10663
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10401
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10416
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10138
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7676
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4357
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3881
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3029
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.