Ask a Question related to Dreamweaver AppDev, Design and Development.
-
StantonWeb #1
PHP - download multiple text files by submitting an htmlform
Hello,
I am building a site that allows the user to download a set of text files
based on user selection on HTML forms. For example, the user can choose to
download data starting from year1 = 2005, month1 = Jan, day1 = 1 until
year2 = 2005, month2 = Jan, day2 = 5 (totalling 5 days of data)
I can only get the program to download one text file with all the 5 sets of
data appended to the same text file when the form gets submitted. What I
actually want is to get PHP to download "multiple" and separate text files once
the form get submitted.
I tried to do this for each set of data in the same php script:
$fname = "fileA";
header("Content-Disposition: attachment; filename=$fname", false);
echo $file_contentA;
$fname = "fileB";
header("Content-Disposition: attachment; filename=$fname", false);
echo $file_contentB;
...same thing for fileC, fileD, and file E
I tried to have multiple of these headers and printing the file contents in
different places throughout the program hoping to get downloads of multiple
files.
PHP is recognizing only one headers at a time (i.e. only downloads 1 file at a
time). Thus, all the "echo filecontent" statements go into the same destination
file.
How can I have downloads of multiple files? so that filecontent A, B, C, D, E
can be 5 separate files when downloaded? is it possible to download more than 1
file at a time?
Question2:
If it is only possible to download 1 file at a time, how can I "create" 5
files, get them zipped, and let the user download that product zip file?
I could not find any "create zip file" functions through php.net and
phpbuilder.com
Thanks a lot!
Stanton
StantonWeb Guest
-
Multiple emails when submitting a form?
Does anyone know whether or not you can have a form submit to multiple email address' when you submit a form? Especially when you distribute the... -
Multiple files download?
Originally posted by: 2JZ Hi all, I am using FileReference's download() to download file. However, it seems that donwload() only donwload one... -
Loading Multiple Text files
Hi! I've got several archived text files - 040107.txt, 040207.txt, 040307.txt, for example - and I want to be able to build a dynamic link which... -
Submitting data from single tab using multiple tab form
I have a flash form with multiple tabs. When a submit button is pressed, however, I would like only the information from the current tab to go to... -
Submitting multiple record IDs via a form.
I have a problem more to do with style than ability; I can solve this problem in a number of ways, but I'm keen to find the best way of doing... -
Michael Fesser #2
Re: PHP - download multiple text files by submitting an html form
.oO(StantonWeb)
That's how HTTP works: First the headers, then the content. You can't>PHP is recognizing only one headers at a time (i.e. only downloads 1 file at a
>time). Thus, all the "echo filecontent" statements go into the same destination
>file.
send additional headers after the content has been sent. PHP will
complain about that with a warning unless you use output buffering.
No. One request, one response.>How can I have downloads of multiple files? so that filecontent A, B, C, D, E
>can be 5 separate files when downloaded? is it possible to download more than 1
>file at a time?
PHP is capable of reading and writing .gz files, at least WinZip is able> Question2:
> If it is only possible to download 1 file at a time, how can I "create" 5
>files, get them zipped, and let the user download that product zip file?
> I could not find any "create zip file" functions through php.net and
>phpbuilder.com
to decompress them.
CXL. Zlib Compression Functions
[url]http://www.php.net/manual/en/ref.zlib.php[/url]
Another way would be to use an external program on the server to create
the archive, but this depends on the server and the installed software.
On a *nix machine it should be possible.
Micha
Michael Fesser Guest



Reply With Quote

