자바스크립트에서 php 함수 호출 문의

자바스크립트에서 php 함수 호출 문의

QA

자바스크립트에서 php 함수 호출 문의

답변 2

본문

안녕하세요 . 자바스크립트에서 php 함수 호출 문의때문에 질문 등록합니다.


<input type="button" value="메뉴얼 다운로드" onclick="manual_file(2)" >
 
//////////////////////////////////////////////////////////////////////////////////////
 
<script>
function manual_file(str){
    if(str==2){
        alert("<?=dfile(3)?>"); 
    }
}
</script>
 
///////////////////////////////////////////////////////////////////////////////////
 
<?
function dfile($c){
    $b=$c;
if($b==3){
$filename = "./test.txt";                      
$reail_filename = urldecode("test.txt");    
$file_dir = "./manual/test.txt";  
header('Content-Type: application/x-octetstream');
header('Content-Length: '.filesize($file_dir));
header('Content-Disposition: attachment; filename='.$reail_filename);
header('Content-Transfer-Encoding: binary');
$fp = fopen($file_dir, "r");
fpassthru($fp);
fclose($fp);
    }else{
        echo "실패";
    }
 
    } 
 
?>

 

1. 자꾸 자동 다운로드 가 진행되네요...함수쪽에서 바로 실행되는것같은데..어떻게 해결해야 좋을까요?


2. 웹뷰에서 이런식으로 파일다운로드를 구현할 건데요 동작이 가능할까요? 

이 질문에 댓글 쓰기 :

답변 2

답변을 작성하시기 전에 로그인 해주세요.
QA 내용 검색
질문등록
전체 44
© SIRSOFT
현재 페이지 제일 처음으로