2012-08-07 2 views
3

내가 파일 다운로드에 CodeIgniter의에 문제가 있어요 다운로드하지만 난 CodeIgniter의에서 코드를 넣을 때 파일이 성공적으로 다운로드됩니다, .하지만 손상 :(PHP - CodeIgniter는이 코드는 단독으로 PHP 파일에 완벽하게 작동</p> <p>.. 원격 파일

참고했다 : 나는 원격 서버에서 비디오 파일을 함께 일하고 있어요

코드 :.

$file = fopen ($link, "r"); 
if (!$file) { 
    echo "<p align='center' style='color:#FF0101;'>Unable to open remote file :(, Please try again in a few minutes.</p>"; 
}else{ 
    ob_clean(); 
    header("Pragma: public"); 
    header("Expires: 0"); 
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 
    header("Content-Type: application/force-download"); 
    header("Content-Type: application/octet-stream"); 
    header("Content-Type: application/download"); 

    header('Content-Disposition: attachment; filename=zxc.3gp'); 
    //header("Content-Transfer-Encoding: binary"); 
    //header("Content-Length: ".$video_size); 


    while (!feof ($file)) { 
     $line = fgets ($file, 1024); 
     echo $line; 
     ob_flush(); 
     flush(); 
    } 
    fclose($file); 
    die(); 
} 

나는 새로운 CodeIgniter의 프로젝트에서이 코드를 시도 :

public function index() 
{ 
    $link = 'http://mamprogr.net.tc/tmp/1.3gp'; 
    $this->load->helper('download'); 
    force_download('1.3gp',$link); 
} 

하지만 도움이된다면 :(

+0

무엇이 질문입니까? 무슨 일 이니? 오류 메시지가 있습니까? [당신은 무엇을 했습니까?] (http://www.whathaveyoutried.com) – orourkek

+1

CodeIgniter [출력 클래스] (http://codeigniter.com/user_guide/libraries/output.html)! <- 해당 페이지를 참조하십시오. 어떻게 문제를 해결할 수 있을지 모르지만 문제는 _ 문제입니다. – Prasanth

+0

출력을 gzip으로 압축하고 있습니까? 그렇다면 문제가됩니다. gzip 압축이 활성화 된 경우 컨트롤러 메서드에서 직접 내용을 출력 할 수 없습니다. 보기를 사용해야합니다. – Brendan

답변

4

는 CodeIgniter의의 force_download() 도우미를 시도하고 볼이 작동하지 않습니다

force_download($name, $data); 

UPDATE

당신이 force_download() 함수에 대한 두 번째 매개 변수로 직접 링크를 제공하려했으나 "dat a "- 아래 참조 -

$data = file_get_contents("/local/path/to//1.3gp"); // Read the file's contents 
//or perhpas $data = fopen(......); 
$name = '1.3gp'; 

force_download($name, $data); 
+0

그는 특히 ob_flush() 속성을 이용하려고하기 때문에 그렇지 않을 수도 있습니다. force_download가 스트리밍을 허용하는지는 이제 문제입니다. – Prasanth

+0

작동하지 않습니다 .. 파일을 다운로드했지만 작동하지 않는 파일 .. 로컬이 아닌 원격 파일을 사용하고 있습니다! – MAMProgr

+2

@MAMProgr - URL 대신 데이터를 제공해야합니다. 내 업데이트를 참조하십시오. – TigerTiger

0

귀하의 솔루션은 다운로드 문제를 해결합니다. 그러나 파일을 재생할 때 errro가 표시됩니다.

Windows Media Player에서 파일을 재생할 수 없습니다. 플레이어가 파일 형식을 지원하지 않거나 파일 압축에 사용 된 코덱을 지원하지 않을 수 있습니다.

퀵타임과 리얼 플레이어를 시도했지만 여전히 비디오 재생을 거부합니다.