[apache서버/php] 이미지 저장하기

프로그래밍/서버2020. 1. 29. 23:54

서버에 파일/이미지를 저장할 때 참고할만한 글들을 링크로 남깁니다.

 

https://stackoverflow.com/questions/348363/what-is-the-best-place-for-storing-uploaded-images-sql-database-or-disk-file-sy

I generally store files on the file-system, since that's what its there for, though there are exceptions. For files, the file-system is the most flexible and performant solution (usually).

There are a few problems with storing files on a database - files are generally much larger than your average row - result-sets containing many large files will consume a lot of memory. Also, if you use a storage engine that employs table-locks for writes (ISAM for example), your files table might be locked often depending on the size / rate of files you are storing there.

Regarding security - I usually store the files in a directory that is outside of the document root (not accessible through an http request) and serve them through a script that checks for the proper authorization first.

 

https://stackoverflow.com/questions/3131562/serving-images-from-outside-of-document-root

<?php
  header('Content-Type: image/jpg');
  readfile("../img/" . $_GET['img']);
?>

 

보안 관련

https://mytory.net/archives/3011

작성자

Posted by 드리머즈

관련 글

댓글 영역