FTP 프로토콜을 통해 원격 NAS 하드 디스크의 파일을 검색하고 json 파일을 생성 한 다음 javascript를 통해 해당 파일을 브라우저에 나열하는 PHP가 있습니다.ftp : // 링크로 강제 다운로드
사용자가 mp4, jpg 및 많은 브라우저에서 알려진 형식에 대한 링크를 클릭하면 브라우저는 다운로드하는 대신 te 내용을 엽니 다.
이제는 PHP 또는 .htaccess를 사용하여 브라우저에서 파일을 다운로드하도록 헤더를 변경할 수 있지만 파일은 원격 위치에 있으며 PHP를 통해 액세스 할 수 없으므로 PHP를 실행할 수 없습니다. .htaccess 안에.
내가 PHP에서이 헤더 변화 시도:
header("Content-Type: application/octet-stream");
header("Content-Transfer-Encoding: Binary");
header("Content-Disposition: attachment; filename=\"$file\"");
또는
header("Content-Description: File Transfer");
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"$file\"");
또는
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=$file");
header("Content-Type: application/image");
header("Content-Transfer-Encoding: binary");
모든
로 끝나는 :header("Location: $url");
을
(URL이 ftp://user:[email protected]/folder/file.mp4 인)하지만 항상
어떤 아이디어 (물론 인식 된 파일 확장자) 다운로드하는 대신 브라우저에서 파일을 엽니 다? 감사합니다
생성하는 URL이 NAS를 직접 가리키고 있습니까? 그렇다면 NAS와 브라우저 사이의 중개자 역할을하는 웹 응용 프로그램을 제공 할 수 있습니다.이 경우 원하는 모든 헤더를 추가 할 수 있습니다. – Tarik