1

thanks for help..

I'm using cURL for submit via POST a PHP file

    $curl = curl_init();
    // Set some options - we are passing in a useragent too here
    curl_setopt_array($curl, array(
        CURLOPT_RETURNTRANSFER => 1,
        CURLOPT_URL => 'http://www.******.php',
        CURLOPT_TIMEOUT => 5000,
        CURLOPT_POST => 1,
        CURLOPT_POSTFIELDS => array(
            val1 => 3,
            val2 => 1
        )
    ));
$resp = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
echo $httpCode;
curl_close($curl);

The php file response with this:

<META HTTP-EQUIV='Refresh' CONTENT='1; URL=/******.pdf'>

My script refresh the page searching for the file .pdf in my domain (error 404).. I want that the script download this file in my server in a specific path with the original name..

Could anyone help me?

Joe
  • 145
  • 1
  • 1
  • 11
  • Parse the response html with DomDocument then make a second request for the PDF file – jedifans Aug 25 '16 at 20:36
  • ok now I try! There is a way to avoid the refresh of the page with the script? – Joe Aug 25 '16 at 20:40
  • I wouldn't have imagined curl would follow a returned meta http-equiv tag. Are you seeing that behaviour? – jedifans Aug 25 '16 at 20:41
  • I tracked timeline via google chrome and the script redirect me to mysite.com/original_file.pdf... – Joe Aug 25 '16 at 20:43
  • Are you printing out the fetched content to the page? Your example only had http code being printed. – jedifans Aug 25 '16 at 20:45
  • if I do "echo $resp;" I don't see nothing and the page refresh.. – Joe Aug 25 '16 at 20:47
  • Yep, don't print out the curl response, or that meta tag will be shown your browser and it will happily follow it. Instead, parse the response. – jedifans Aug 25 '16 at 20:49

0 Answers0