Re: How to get the original filename of a downloading file.
Date: Thu, 10 Oct 2002 13:26:08 +0200 (MET DST)
On Thu, 10 Oct 2002, [gb2312] 王 臻 wrote:
> I know there's no original filename associated with a URL. But if a URI
> is directly linked to a file, such as
> http://www.someserver.com/download.zip. We know it is a zip file and named
> as "download.zip". But bucause jsp and asp use middle ware, the middle
> layer server receives our request and gets a file from other place differ
> from the original URL such as "http://www.someserver.com/request01.jsp". My
> question is , how to get the filename when the stream arrives. Thanks.
Since there is no filename associated with a URL, how can there be a file
name for you to get "when the stream arrives" ?
The answer is: there is no file name. A stream from a given URL has no file
name. You may pick any file name you want to store it locally, but you can
never have any clue what the "original" or "real" file name might be in the
other end. It might not even be a file. You just can't tell.
Browsers generally solve this by querying the user (mostly using the
rightmost part of the URL as default in the prompt). Script writers solve
this by inventing a name to download it as, and then possibly rename it later
if analyzing the package might bring up a suitable name.
However, of course there might be special servers that somehow offers a file
name for the URL somehow. It is however not a standard URL (or even HTTP)
-- Daniel Stenberg -- curl, cURL, Curl, CURL. Groks URLs. ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sfReceived on 2002-10-10