|
Thank Jacob, for your patient help.
I got the same results after apply the
realpath.
I will still try to work it out. If it does not work, I
will probably let php call the gzip command to do the task, and
put the
output file in a temp folder and remove afterwards. Let me
try ... See what will happen
Best,
Xiaopeng
----- Original Message -----
Sent: Sunday, October 15, 2006 10:47
PM
Subject: Re: [UMN_MAPSERVER-USERS] Enable
zip file downloading from query results
It is probably because of your add_dir. Try doing
this:
$zipdir = realpath(./yourfile.img);
add_dir($zipdir);
basically, realpath turns a relative path into an
absolute path. This is the approach I have used to get the right path for this
script.
regards,
Jacob
This is great. Yes I think I will probably go this way you suggested. Thanks for the
hints.
But I found a small problem when use the
zipfile.php. After I downloaded the zipped file to my windows
machine via the zipfile.php, I could not use "extract to here" or
"extract to folder XXX" of the Winzip functionality, it complains that
"start of central directory not found; Zip file corrupt. Possible cause:
file transfer error.". But I was enable to double
click the .zip file and activate the Winzip window, then get individual
files out in this way.
I am not sure whether I used the zipfile class right,
I passed "./" to add_dir() since the files to be zipped are in the same
directory as the .php file, and repeated passed a file name (e.g.,
test1.txt) to add_file().
Thanks,
Xiaopeng
----- Original Message -----
Sent: Sunday, October 15, 2006 7:37
PM
Subject: Re: [UMN_MAPSERVER-USERS]
Enable zip file downloading from query results
Hi Xiaopeng,
I think for a single file, you can
do:
<a
href="">download zipped
file</a>
For downloading all files, I don't think there is a
very straightforward way to do this, except by building up a URL on the
fly. Perhaps you could use _javascript_ to add to the URL, for example at
the beginning of the template put:
url="";
and then for each record, do:
url+="[filename],";
then at the end of the
template:
url+="'>download
all</a>";
document.write(url);
This is untested code, but I think that's how I
would go about it. You would have to change zipfile.php to read in url,
and use "explode" to get the file from the comma delimited
list.
regards,
Jacob
Thanks for the help. It works on the server
side.
But there are still another part of the
problem. When the query result is returned to the
query template, how to access the "FileLink"
attribute of each record? And how to
send these FileLinks to server side PHP
file?
Thanks,
Xiaopeng
----- Original Message -----
Sent: Thursday, October 12, 2006
11:29 PM
Subject: RE:
[UMN_MAPSERVER-USERS] Enable zip file downloading from query
results
Hi Xiaopeng,
There is a file from "Catalist
Creative" on their website, which does that:
I have used it a fair bit for this
purpose. You basically have to modify it to point to the right files.
If you use it, please make the following change, otherwise you will
run into problems if you try to open the zip-file straight from
Internet Explorer:
Before the lines that say "Header
("Content ........", put another line that says:
Header("Cache-Control:
must-revalidate, post-check=0, pre-check=0");
regards,
Jacob
Hello List,
I am very new to this field. I
apologize if this question is not related but I do appreciate
any suggestions.
I have one index that can be queried using
mapserver. The query results are like follows:
Record |
UL_X |
FileLink
Now what I want to realize is to provide an
additional "Download_All" button in the query result
page.
Then when the user clicks
the "Download_All" button, all the files in
"FileLink" will be compressed online
into one (e.g., .zip) file and
downloaded.
How can this be realized? I'll apprecate any
help or some reference to read.
Thank you.
Best,
Xiaopeng
|