optikalefx Posted August 26, 2010 Share Posted August 26, 2010 Is this possible? I have a PHP file that serves a file (which is below the web root). That works fine and the download dialog is presented when directly accessed. Im building and API however, and that file needs to be served via HTTP Request. Im trying to get it working with cURL but right now its just outputting the raw byte data to the screen. Anyone had success or know what I need to try to be able to call that PHP file with cURL and have the browser try to download the file? (i've tried a lot of combinations of settings for this) $ch = curl_init(); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_URL,$remote); curl_setopt($ch,CURLOPT_BINARYTRANSFER,1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $nvp); return curl_exec($ch); // side note I'm hoping the cURL settings don't matter too too much because a C# program will need to request the download. Quote Link to comment Share on other sites More sharing options...
btherl Posted August 26, 2010 Share Posted August 26, 2010 Sounds like you need to change the HTTP headers. Here's what microsoft says about it: http://support.microsoft.com/kb/260519 Quote Link to comment Share on other sites More sharing options...
optikalefx Posted August 27, 2010 Author Share Posted August 27, 2010 well the headers work well on their own, just not when curl is involved. Is there a way to carry the headers through curl? I know there is a CURLOPT_HEADER that when true it just prints the headers to screen. :/ Quote Link to comment Share on other sites More sharing options...
btherl Posted August 31, 2010 Share Posted August 31, 2010 You'll need to set the headers yourself if you are fetching a file with curl and then displaying it yourself. Rather than copying the original headers I would just set the ones you need using header(). Quote Link to comment 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.