사이트 내 전체검색
PHP
파일업로드시 이미지 체크 다른 루틴 ( mime 체크)
로빈아빠
https://cmd.kr/php/839 URL이 복사되었습니다.

본문

$file = $_FILES[image];

$size = getImageSize($file[tmp_name]);
$mime = array('image/png', 'image/jpeg', 'image/gif');

if (!is_uploaded_file($file[tmp_name]))
    alert_only("첨부파일이 업로드되지 않았습니다.\\n\\n$file[error]");

if ($file[size] > $byte)
    alert_only("$byte byte 까지 업로드 가능합니다.");

if (!in_array($size['mime'], $mime))
    alert_only("PNG, GIF, JPG 형식의 이미지 파일만 업로드 가능합니다.");

if (!preg_match("/\.(jpg|png|gif)$/i", $file[name]))
    alert_only("PNG, GIF, JPG 형식의 이미지 파일만 업로드 가능합니다.");

if (!is_dir($path))
    alert_only("$path 디렉토리가 존재하지 않습니다.");

if (!is_writable($path))
    alert_only("$path 디렉토리의 퍼미션을 707로 변경해주세요.");

댓글목록

등록된 댓글이 없습니다.

PHP
871 (3/18P)

Search

Copyright © Cmd 명령어 18.224.61.19