wget 제공되는 파일명으로 다운로드

1 개요[ | ]

wget 제공되는 파일명으로 다운로드
wget 파일명 헤더로부터 받기
  • --content-disposition 옵션을 붙이면 된다.
wget --content-disposition 'URL주소'
wget 'URL주소' --content-disposition

2 실습[ | ]

  • 그냥 wget 으로 받으면, URL 끝부분인 download1.php로 받아짐
root@zetawiki:~# wget http://example.zetawiki.com/php/download1.php
... (생략)
100%[=================================================>] 12          --.-K/s   in 0s      

2016-10-07 18:15:32 (1.94 MB/s) - ‘download1.php’ saved [12/12]
  • --content-disposition 옵션을 붙이면, 서버에서 제공하는 파일명인 hello_world.txt로 받아짐
root@zetawiki:~# wget http://example.zetawiki.com/php/download1.php --content-disposition
... (생략)
100%[=================================================>] 12          --.-K/s   in 0s      

2016-10-07 18:15:38 (2.23 MB/s) - ‘hello_world.txt’ saved [12/12]
  • curl 로 제공되는 파일명을 확인할 수도 있음
root@zetawiki:~# curl -Is http://example.zetawiki.com/php/download1.php | grep Content-Disposition
Content-Disposition: attachment; filename="hello_world.txt"

3 같이 보기[ | ]

4 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}