답변 4개
답변에 대한 댓글 5개
댓글을 작성하려면 로그인이 필요합니다.
댓글을 작성하려면 로그인이 필요합니다.
php에서 다운로드 시키는 방법이 궁금하신건가요?
<?php
$filepath = './hello_world.txt';
$filesize = filesize($filepath);
$path_parts = pathinfo($filepath);
$filename = $path_parts['basename'];
$extension = $path_parts['extension'];
header("Pragma: public");
header("Expires: 0");
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename='$filename'");
header("Content-Transfer-Encoding: binary");
header("Content-Length: $filesize");
ob_clean();
flush();
readfile($filepath);
이런식으로 다운로드 할수 있습니다.
답변에 대한 댓글 1개
파일을 다운시키려는데 대상이 php 파일로 파일을 다운로드 시킵니다. 원본명이 있는게 아닙니다
댓글을 작성하려면 로그인이 필요합니다.
file_get_contents로 서버에 저장시킨다구요...? 흠... 그건 어떻게 하는지... 전 이런식으로 외부 주소 가져와서 저장시켯습니다~
$info['images'] = $image->url;
$img_link = iconv('utf-8','euc-kr',$info['images'][$i]);
$ext = strtolower(pathinfo($img_link, PATHINFO_EXTENSION));
// 저장할 이미지명을 정한다.
$img = $temp_id[1]."_".$i.'.'.$ext;
$info['real_images'][$i] = $path.$img;
$fp = fopen($path.$img,'w'); // 저장할 이미지 위치 및 파일명
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $img_link );
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$contents = curl_exec($ch);
curl_close($ch);
// fwrite($fp,file_get_contents($img_link)); // 가져올 외부이미지 주소
fwrite($fp,$contents); // 가져올 외부이미지 주소
fclose($fp);
답변에 대한 댓글 1개
/bbs/download.php로 파일을 다운로드 하는데,
위와 같은 방법으로 파일을 다운로드할 수 있을까요?
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인