2013-10-22 3 views
0

안녕하세요, joomla 프런트 엔드에서 파일을 다운로드하려고합니다. 내 기본 템플릿에서 PHP 코드를 사용합니다. $full 전체 경로이고 코드 = http://localhost/joomla/images/uploads/images22.jpegphp와 joomla에서 강제 파일 다운로드

<form><input type="button" value="Download Now" onClick="window.location.href='<?php echo $full;?>'"> 

이다. 하지만이 파일을 다운로드하지 않는 브라우저에서만 표시합니다. 버튼을 클릭하여 다운로드하려면 어떻게해야합니까?

+0

http://stackoverflow.com/questions/5648967/force-browser-to-download-image-with-javascript-window-open – Arunu

+0

선생님, 내가 다른 페이지로 이동 싶지 않다. 게시 된 링크는 window.open을 사용하고 있으며 다른 페이지로 전달됩니다. 왜냐하면 나는 joomla 구성 요소 템플릿에서 PHP를 작동하고있어 다른 페이지로 갈 수 없어. 나는 같은 페이지 자체에서 파일을 다운로드해야합니다. – user007

+0

window.open 대신 window.location.href를 사용할 수 있습니다. 다운로드 링크를 만드는 방법에 대한 아이디어를 얻으려면이 링크를 선택하십시오. http://webprogram4beginners.blogspot.in/2011/02/how-to-make-download-link.html – Arunu

답변

0

당신은 .. 파일 다운로드를 강제로 내가 파일이 어떻게 구성되어 있는지 확실하지 오전

$file = "image.jpg"; 
header('Content-Description: File Transfer'); 
header("Content-type: image/jpg"); 
header("Content-disposition: attachment; filename= ".$file.""); 
readfile($file); 

같은 뭔가가 필요하지만, 당신이 원하는 경우에 이것은 당신이

같은 간단한 그렇게 할 수있는 버튼을 클릭하여 수행
<a href='download.php?file=k'>file</a> //or use a button with jquery.. or a reg submit button 

다음이 그것을 할 수있는 가장 간단한 방법입니다

if ($_GET ['file'])) //run code above adding the correct file name, also please remember 
that you will need to add some security here, I am not going to do it for you 

않습니다.

+0

하지만 버튼을 클릭하면 파일을 다운로드해야합니다. 그렇다면이 코드를 어디에서 작성해야합니까? – user007

+0

수표를 다시 업데이트했습니다. – xlordt

+0

답장을 보내 주셔서 감사합니다.