i have a short php script that creates a gz compressed file, but...
when i try to download it, internet explorer doesn't prompt me for a
download location, and then save it at that download location...
instead, it just opens it as it would any old text document... this
is not what i want it to do... i want to be able to download it, not
view it. any ideas on how to do this?
here's the code:
<?
system("ls -l | gzip > test.gz");
print "download <a href=test.gz>he re</a>";
?> 3 4931
Après mure réflexion, "yawnmoth" a écrit : i have a short php script that creates a gz compressed file, but... when i try to download it, internet explorer doesn't prompt me for a download location, and then save it at that download location... instead, it just opens it as it would any old text document... this is not what i want it to do... i want to be able to download it, not view it. any ideas on how to do this?
here's the code:
<? system("ls -l | gzip > test.gz"); print "download <a href=test.gz>he re</a>"; ?>
Well you can always right click on the link and 'save
as...'...
--
SeeSchloß - http://www.seeschloss.net
> > <? system("ls -l | gzip > test.gz"); print "download <a href=test.gz>he re</a>"; ?>
Your Webserver seems to not send the correct mime-type of the downloaded
file.
Try sending the mime-type on your own using the header() and send the
filedata manually instead of providing a download link.
$fp = fopen("test.gz" ,"rb");
$size = filesize("test. gz");
$content = fread($fp,$size );
fclose($fp);
Header('Content-Type: application/x-zip');
Header('Content-Length: '. $size);
Header('Content-disposition: inline; filename=test.g z');
print $content;
}
(not sure with the mime-type .. you better look it up!)
timo
On Tue, 30 Sep 2003 19:01:15 +0200, "Timo Henke" <we*******@fli7 e.de>
wrote: > <? > system("ls -l | gzip > test.gz"); > print "download <a href=test.gz>he re</a>"; > ?>
Your Webserver seems to not send the correct mime-type of the downloaded file.
Try sending the mime-type on your own using the header() and send the filedata manually instead of providing a download link.
$fp = fopen("test.gz" ,"rb"); $size = filesize("test. gz"); $content = fread($fp,$size ); fclose($fp);
Header('Content-Type: application/x-zip'); Header('Content-Length: '. $size); Header('Content-disposition: inline; filename=test.g z'); print $content; }
(not sure with the mime-type .. you better look it up!)
timo
that header command looks pretty nifty - thanks! :D This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Dennis Hotson |
last post by:
Hi,
I'm trying to write a function that adds a file-like-object to a
compressed tarfile... eg ".tar.gz" or ".tar.bz2"
I've had a look at the tarfile module but the append mode doesn't support
compressed tarfiles... :(
Any thoughts on what I can do to get around this?
|
by: Ron Clarke |
last post by:
Does anyone know how to get the compressed size of a file on disk?
FileInfo.Length gives the uncompressed size of a file, but I need to find
the amount of disk space taken up by files in compressed directories
(Windows XP). Getting the "compressed" attribute is available, but how does
one get the compressed size?
Thanks in advance.
--
Ron Clarke
|
by: robert |
last post by:
Hello,
I want to put (incrementally) changed/new files from a big file tree
"directly,compressed and password-only-encrypted" to a remote backup
server incrementally via FTP,SFTP or DAV.... At best within a closed
algorithm inside Python without extra shell tools.
(The method should work with any protocol which allows somehow read,
write & seek to a remote file.)
On the server and the transmission line there should never be...
|
by: KJ |
last post by:
I am using the System.Compression.GZipStream class, and I noticed that
in certain cases, the resultant compressed file is actually larger than
the original. This is almost a constant when compressing
already-compressed formats such as jpeg.
Another less-consistent example of this behavior is found in the case
of compressing TIFFs, wherein some files end up greatly compressed (the
larger ones up to 93% compression ratio) and others end up...
|
by: rony_16 |
last post by:
Hi,
I have a problem downloading a file .
after i connect to the website and get the stream , i treing to write
the file on the HD.
public void SaveStreamToFile(string filePath, Stream stream)
{
// If not all data was provided return false;
//if (string.IsNullOrEmpty(filePath) || stream == null)
// return false;
// System.IO.Stream gzStream = stream; //= new
| |
by: Chuck Renner |
last post by:
Please help!
This MIGHT even be a bug in PHP!
I'll provide version numbers and site specific information (browser, OS,
and kernel versions) if others cannot reproduce this problem.
I'm running into some PHP behavior that I do not understand in PHP 5.1.2.
I need to parse the HTML from the following carefully constructed URI:
|
by: MadMonk |
last post by:
Hi,
I need to write a small Windows application (console or forms) (for Windows
XP SP2 & Windows Server 2003), which will check a folder for the presence of
some files, and if they exist, it will zip the files using the inbuilt
Compressed files functionality of Windows (same as the Context Menu -Send to
-Compressed (zipped) folder).
I cannot use any other third party tool (like winzip etc.) because of some
non-technical constraints.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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...
|
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...
|
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,...
| |
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |