curl-library
Re: Using libcurl to return filename
Date: Thu, 10 Aug 2006 11:17:59 -0700
On Thu, Aug 10, 2006 at 04:08:12PM -0000, man_at_tfhs.net wrote:
> On Thu, Aug 10, 2006, securehell_at_hushmail.com said:
> > In all cases I want the filename of the actual file downloaded
> > whether it is "index.html" or "setup.exe".
> >
> > Can libcurl return this information in a callback? I cannot seem to
> > find it in any of the man pages or even the curl headers.
>
> you cant find it, cause its not available. unless the server sends a
> redirect back to you telling you that www.server.com is really
> /index.html, you have no way of knowing what the filename was. In fact,
> there may have been no file at all, think about mod_perl type websites...
Some servers will send an HTTP header giving the actual file name returned,
but these are few and far between. Besides the Location: header mentioned
above, I've seen headers like:
Content-Disposition: attachment; filename=filename.ext
for some file downloads, but I've also seen some servers give a
Content-Location: header on some normal HTML pages containing the file
name (e.g. http://www.bctechnology.com/)
>>> Dan
-- http://www.MoveAnnouncer.com The web change of address service Let webmasters know that your web site has movedReceived on 2006-08-10