Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Opening forced-download url with PHP (content-disposition: attachment)

0 views
Skip to first unread message

Josh

unread,
Jan 27, 2004, 7:47:05 PM1/27/04
to
I'm writing a web scraper, and the file I'm downloading returns the
following header: Content-Disposition: attachment; filename=Slate
1-27-04.htm

Consequently, the fopen() call doesn't return the proper resource.

How do I get to this file?

Thanks,
--Josh

----------------------------------------------
Code:

$body = fopen("http://slate.msn.com/apps/myslate/action/save.aspx?ids=toc",
"r");

foreach ( $http_response_header as $response) {
echo "$response<br>\n";
}

if (!$fp) {
die("error: the file didn't open");
} else {
die("success!");
}


Returns:

HTTP/1.1 200 OK
Server: Microsoft-IIS/5.0
Date: Wed, 28 Jan 2004 00:41:01 GMT
P3P:CP="BUS CUR CONo FIN IVDo ONL OUR PHY SAMo TELo"
X-Powered-By: ASP.NET
X-AspNet-Version: 1.1.4322
Content-Disposition: attachment; filename=Slate 1-27-04.htm
Cache-Control: private
Content-Type: text/x-anything; charset=utf-8
Content-Length: 852060
error: the file didn't open


Christian Meisinger

unread,
Jan 28, 2004, 3:39:06 AM1/28/04
to
On Tue, 27 Jan 2004 19:47:05 -0500, Josh <jo...@joshwand.NOSPAM-REMOVE.com>
wrote:

> I'm writing a web scraper, and the file I'm downloading returns the
> following header: Content-Disposition: attachment; filename=Slate
> 1-27-04.htm
>
> Consequently, the fopen() call doesn't return the proper resource.
>
> How do I get to this file?
>
> Thanks,
> --Josh
>
> ----------------------------------------------
> Code:
>
> $body =
> fopen("http://slate.msn.com/apps/myslate/action/save.aspx?ids=toc",
> "r");
>
> foreach ( $http_response_header as $response) {
> echo "$response<br>\n";
> }
>
> if (!$fp) {
> die("error: the file didn't open");
> } else {
> die("success!");
> }
>

but above you use $body? shouldn't you check $body instead of $fp?

chris

0 new messages