Download a file that is forced as attachment with PHP

knightschest

New Member
I am trying to download a file with PHP from an FTP server which i can access from http too. For example: \[code\]FTP://username:p[email protected]/file_name_here.gz\[/code\]. The file is forced as an attachment from the server (not as a PDF or TXT would do eg: output). I tried it with 3 different methods:[*]file_get_contents -> Return a zero size file[*]Curl -> times out[*]FTP function -> Returns a zero size fileI think CURL is the way to do it but I can't manage to download the file... Here is my code:\[code\]$curl = curl_init();$url ='ftp://'.$network['username'].':'.$network['password'].'@'.$network['metadata_url'].'/'.$path.'/'.$data['title'];curl_setopt($curl, CURLOPT_URL,$url);//curl_setopt($curl, CURLOPT_USERPWD, "$_FTP[username]:$_FTP[password]");//curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);$file = fopen("./feeds/".$data['title'], "w");curl_setopt($curl, CURLOPT_FILE, $file);$result = curl_exec ($curl);\[/code\]I tried both setting the username and password in the CURLOPT_URL and setting them with CURL. The same thing happens with both of the ways...Can you help?\[code\]Edit\[/code\]: Forgot to mention that the file is served from the server dynamically. So for example the real file is: \[code\]filename.gz.check\[/code\] which when i ommit the \[code\].check\[/code\] part i get the original file. Dunno why they do this but I need to work with this as it is.
 
Top