Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.