473,785 Members | 2,720 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

download via header using flush()?

hi,
i'm looking for a possibility to start a download.

here is my current code:
header("Content-Type: $_contenttype") ;
header("Content-Disposition: attachment;
filename=\"$_fi lename\"");
// flush();
echo $filecontent;
this works fine. however i'm not satisfied with that code because it
seems as if the code first creates the complete file and then sends
the output to the browser. then the browser starts the downloadaction
and the filesize is always 1kb.

what i want the code to do is to start a normal download.
$filecontent will be created after sending the header (this is because
the file is decoded from an email - $filecontent is an
email-attachment).

what i've tried out is adding flush(); after sending the header. i
thought the browser would start the download dialog - however it
doesn't!

is there an additional header-tag that might help me? i've read
something about "content-size: filesize($file) ". but i don't believe
that this might help me!

greets micrix
Jul 16 '05 #1
2 3201
Thomas Kemmerich wrote:
hi,
i'm looking for a possibility to start a download.

here is my current code:
header("Content-Type: $_contenttype") ;
header("Content-Disposition: attachment;
filename=\"$_fi lename\"");
// flush();
echo $filecontent;
this works fine. however i'm not satisfied with that code because it
seems as if the code first creates the complete file and then sends
the output to the browser. then the browser starts the downloadaction
and the filesize is always 1kb.

what i want the code to do is to start a normal download.
$filecontent will be created after sending the header (this is because
the file is decoded from an email - $filecontent is an
email-attachment).

what i've tried out is adding flush(); after sending the header. i
thought the browser would start the download dialog - however it
doesn't!

is there an additional header-tag that might help me? i've read
something about "content-size: filesize($file) ". but i don't believe
that this might help me!

greets micrix

Why wouldn't Content-size help you? Have you tried it? I believe that
is what you are looking for. If you want to avoid all of this stuff,
just do a header redirect via Location.

-Calico Jack-

Jul 17 '05 #2
Calico Jack <sg****@yahoo.c om> wrote in message news:<7I******* **********@bign ews5.bellsouth. net>...
Thomas Kemmerich wrote:
hi,
i'm looking for a possibility to start a download.

here is my current code:
header("Content-Type: $_contenttype") ;
header("Content-Disposition: attachment;
filename=\"$_fi lename\"");
// flush();
echo $filecontent;
this works fine. however i'm not satisfied with that code because it
seems as if the code first creates the complete file and then sends
the output to the browser. then the browser starts the downloadaction
and the filesize is always 1kb.

what i want the code to do is to start a normal download.
$filecontent will be created after sending the header (this is because
the file is decoded from an email - $filecontent is an
email-attachment).

what i've tried out is adding flush(); after sending the header. i
thought the browser would start the download dialog - however it
doesn't!

is there an additional header-tag that might help me? i've read
something about "content-size: filesize($file) ". but i don't believe
that this might help me!

greets micrix

Why wouldn't Content-size help you? Have you tried it? I believe that
is what you are looking for. If you want to avoid all of this stuff,
just do a header redirect via Location.

-Calico Jack-

I use these
header("Content-type: Aplication/Octet-Stream");
header("Content-disposition: filename=$your_ file_name");
header("Content-length: number_of_bytes ");
header("Filenam e: $your_file_name ");

while(readfile. ...)
print file_contents;

Mike Bradley
http://gzen.myhq.info -- free online php tools
Jul 17 '05 #3

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

Similar topics

4
4735
by: Alexander Gilman Carver | last post by:
I have written a pair of scripts that are supposed to work together to display an index of files and then, upon the user choosing the files (with checkboxes on an HTML form submitted to itself), tar/gzip the file and send it to them. To this end the first script performs an exec() call and generates the archive (it's a random number but we'll call it foo.bar.tar.gz) and then writes a META tag into the page after it submits the HTML form...
7
1879
by: Daedalus | last post by:
Hi, I have made a php page where people can configure a javascript online with a preview and then dowload the result. Here is the code: <? // Some code that create a temp file ($file handler = $fd) and write the script // Send the file header("content-type: text/plain"); header("Content-length: ".filesize($file)); header('Content-Disposition: attachment; filename="script_name.js"');
12
1430
by: Jerry Camel | last post by:
I thought I had finally figured out how to control the downloads from my page. I was having issues with large files, but after much research I came up with the following code. The download seems to proceed without issue, but never terminiates. The byte count stops incrementing, but the dowload dialog never closes. (Until I hit cancel.) What's keeping the download from ending properly? I'm pretty close to finishing this app - any help is...
3
2467
by: Bouffa | last post by:
Hello everyone, I suppose you all know force-download scripts. The problem is that these scripts don't allow files to be splitted when downloading them via a download manager. I've found a solution to enable download resuming, but now, it remains the splitting problem. Does anyone have any idea ?
4
2507
by: rony_16 | last post by:
Hi, I have a program that connects to a site With WebRequest and WebResponse . The response of this site is a file (csv file). The problem is that the file do not comes as a stream , hi is a part of the header (Content-Disposition:attachment; filename=changehistory.csv) i tried to download this file as a stream , but it do not work . i triesd with WebClient , but i coudn't attache a cookieContainer to him . (Connectiong to LogIn)
0
2680
by: jinnareddy | last post by:
Hi, I'm unable to download a file that is having a 2-byte char in its name (e.g.テ) using force download option. Though, am able to download file names involving ASCII chars. I have tried URL encoding too, but with no success. Can someone provide details on how to handle the 2-byte char URLs and download the files? Appreciate your suggestions/help in resolving it. Here is my code:
5
1839
by: muriwai | last post by:
Hi, I manually stream out a file in chunks from my web form using PageAsyncTask, Page.Response.OutputStream.BeginWrite and Flush after each chunk. I do set the Content-Length header. If an error occurs (for example, a timeout), I do the following: response.OutputStream.Close(); response.Flush(); response.Close();
6
1677
by: empiresolutions | last post by:
Using the following code, files greater than 10Megs do not download. Less than 10 is working. Can anyone explain why? Files that will be downloaded are 5G plus in size. function download() { global $_GET; //Gather relevent info about file $file = "/user/dac420/tts/incoming/".$_GET; $len = filesize($file);
10
19368
by: =?Utf-8?B?SnVhbg==?= | last post by:
Hi! I want to use ASP to download big files using ADODB.STREAM. It works very fine with files smaller than 80 MB. On the Webserver I can see that memory allocation and the process w3wp is running. After some time (more or less 2 minutes) I get a response timeout. Here is the code:
1
10087
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
8971
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7496
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...
0
6737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5380
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4046
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
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2877
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.