antonyjohn Posted September 2, 2008 Share Posted September 2, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/122358-curl-problem/ Share on other sites More sharing options...
JonnoTheDev Posted September 2, 2008 Share Posted September 2, 2008 Not sure if this is possible without the actual remote file location. The remote script is obviously using a file header to prompt a download Quote Link to comment https://forums.phpfreaks.com/topic/122358-curl-problem/#findComment-631816 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.