Jump to content

CURL problem


antonyjohn

Recommended Posts

hi,

 

  i have url which gives me the output in the form of a zip file by prompting me for a download.this file exits in a different server which i dont have access, i only know the url

 

i have writen a code in CURL which helps me to retirve the results from my server. the code is as below

 

<?

function curlHeaderCallback($resURL, $strHeader) {

    if (preg_match('/^HTTP/i', $strHeader)) {

        header($strHeader);     

        header('Content-Disposition: attachment; filename="file-name.zip"');     

    }

    return strlen($strHeader);

}

 

$strURL = 'http://www.xyz.com/download_inventory_excel/AlpineCreationsFeed.asp?format=csv&item_type=1';

 

$resURL = curl_init();

curl_setopt($resURL, CURLOPT_URL, $strURL);

curl_setopt($resURL, CURLOPT_BINARYTRANSFER, 1);

curl_setopt($resURL, CURLOPT_HEADERFUNCTION, 'curlHeaderCallback');

curl_setopt($resURL, CURLOPT_FAILONERROR, 1);

 

curl_exec ($resURL);

 

$intReturnCode = curl_getinfo($resURL, CURLINFO_HTTP_CODE);

curl_close ($resURL);

?>

it gives the desired results, but i dont want it to prompt me for download, i need it to save it to to location i assign.

 

Link to comment
https://forums.phpfreaks.com/topic/122358-curl-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.