.htaccess - Download htaccess protected files using PHP and CURL -


i tried download files in htaccess protected directory using php , curl. code:

$username = "myusername"; $password = "mypassword"; $url = "http://www.example.com/private/file.pdf"; $ch = curl_init(); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_returntransfer, true); curl_setopt($ch, curlopt_userpwd, "$username:$password"); curl_setopt($ch, curlopt_httpauth, curlauth_basic); $output = curl_exec($ch); $info = curl_getinfo($ch); curl_close($ch); 

but code nothing... how can initiate download of file.pdf?

thank you!

also, if echo $output, this:

array ( [url] => http://www.example.com/private/file.pdf [content_type] => application/pdf [http_code] => 200 [header_size] => 264 [request_size] => 116 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.007898 [namelookup_time] => 0.006777 [connect_time] => 0.006858 [pretransfer_time] => 0.006922 [size_upload] => 0 [size_download] => 27369 [speed_download] => 3465307 [speed_upload] => 0 [download_content_length] => 27369 [upload_content_length] => 0 [starttransfer_time] => 0.007839 [redirect_time] => 0 ) 

there curlopt_binarytransfer option seems missing. output pasted $info not $output btw. shows download happened, download_content_length 27369.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -