[thelist] cURL, PHP and downloading files

Matthias Ritzkowski Matt at grndwtr.com
Tue Jul 2 09:42:01 CDT 2002


Jay -
I just did the same thing by using the header function in php.
Matthias



if (strstr($_SERVER["HTTP_USER_AGENT"], "MSIE"))
{
header("HTTP/1.0 200 OK");
}
header("Content-Type: application/pdf");
header("Content-Disposition: attachment; filename=$file_name");
header("Content-Location: $file_path");
header("content-length: $filesize");
$fp = fopen("$file_path", "r");

  print fread($fp, $filesize);
  fclose($fp);



-----Original Message-----
From: Jay Blanchard [mailto:jay.blanchard at niicommunications.com]
Sent: Tuesday, July 02, 2002 10:08
To: thelist at lists.evolt.org
Subject: [thelist] cURL, PHP and downloading files


Good morning gurus!

I need to download files from an https connection so I have chosen cURL
(http://curl.haxx.se/) to do this. I can do one-off downloads, but I need to
be able to place this information in a PHP script. cURL is run from the
command line so I am using the exec() function thusly;

exec("curl -d \"name=myname&password=mypassword&btnsubmit=submit\" -s -o
cdrlist.html https://theserver.com/list.html");

but why can't I do this

exec("curl -d \"name=myname&password=mypassword&btnsubmit=submit\" -s -o
".$listline." https://theserver.com/download/".$listline."");

Then I put everything in variables, thinking that maybe the exec() function
didn't like concatenation so...

$curlinfo_1 = "\"name=myname&password=mypassword&btnsubmit=submit\"";
$curlinfo_2 = $listline
$curlinfo_3 = "https://theserver.com/download/".$listline";

exec("curl -d $curlinfo_1 -s -o $curlinfo_2 curlinfo_3");

I can insert a print statement and the line looks OK, the syntax is correct.
Has any of you used cURL, or can any of you see if I am leaving something
out? If not I am going to have major troubles setting up an automated
download from the https connection. I probably could do it in PERL, but
would rather not if I don't have to.

Much TIA!

Jay


--
For unsubscribe and other options, including
the Tip Harvester and archive of thelist go to:
http://lists.evolt.org Workers of the Web, evolt !



More information about the thelist mailing list