Forum Moderators: coopster

Message Too Old, No Replies

Http Headers

Download File With header()

         

Khvicha

2:24 pm on Dec 19, 2007 (gmt 0)

10+ Year Member



Hello everyone

I have one problem, I need to download many files(more then one file, but not in compressed mode) from the server, i'm using header() function for that:

header('Content-Type: application/octet-stream;');
header('Content-Disposition: attachment; '.'filename="1.txt"');
readfile("1.txt");
header('Content-Type: application/octet-stream;',false);
header('Content-Disposition: attachment; '.'filename="2.txt"',false);
readfile("2.txt");

,but i receive one download dialogue box(not two) which ask me to save '1.txt' file and content of this file is data from both files(1.txt,2.txt), so i can download one file '1.txt' which contains mixed data from both files;

BUT I NEED RECEIVE TWO DOWNLOAD DIALOGUE BOX - FIRST FOR 1.txt AND SECOND FOR 2.txt.

is it possible?
please, help me enyone....

Thank You

gergoe

5:32 pm on Dec 19, 2007 (gmt 0)

10+ Year Member



Downloading multiple files is only possible in two different http requests. So you have to create a page where the user will be advised to download that two file, and you either use the header method you tried to download each of the files separately (after clicking on one of the files), or you just simply point the links to the psychical path of the files.

Khvicha

8:48 pm on Dec 19, 2007 (gmt 0)

10+ Year Member



so, is it not possible to download two files automaticaly?
i meen with two download dialogue box,

londrum

8:51 pm on Dec 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



you could read the content of both files into a buffer and then save it somewhere. then you could download both of them as one.

Khvicha

11:23 am on Dec 20, 2007 (gmt 0)

10+ Year Member



thank you...