Hey guys. I really need help. I have a script that needs to login and stream a file from a remote server. It logins in fine, but it outputs the file inside the browser with lots of weird symbols. How can I make it put the file up in zip format so that the user can download it right away, without the need to save it to server first. Thanks!!!!!!!!! Here is my script: $cookie_file_path = "cookie.txt"; $useragent='Mozilla 5.0 '; $ch = curl_init(); $LOGINURL = "http://mydomain.com/login.php"; $POSTFIELDS = 'user=test&pass=test&redirect=file.zip'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$LOGINURL); curl_setopt($ch, CURLOPT_USERAGENT, $agent); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS,$POSTFIELDS); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_REFERER, $reffer); curl_setopt($ch, CURLOPT_HEADER,0); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path); $result= curl_exec ($ch); echo $result; curl_close ($ch); Code (markup):
Never mind. Found answers. Works like charm. Here is the code i added at bottom so that it streams the file:
Surely if the file is considerably large, you would run out of memory since $file= curl_exec ($ch); loads the whole file into memory, doesn't it?