파일 업로드 레퍼런스
Server Side/PHP2016. 7. 8. 23:13
0) die("Error uploading file! code $error."); else { if($type=="image/png" || $size > 2000000)//condition for the file { die("Format not allowed or file size too big!"); } else { move_uploaded_file($temp, "uploaded/" .$name); echo "Upload complete!"; } } ////////////////////////// $file = 'somefile.jpg'; # assuming you've already taken some other # preventive measures such as checking file # extensions... $result_array = getimagesize($file); if ($result_array !== false) { $mime_type = $result_array['mime']; switch($mime_type) { case "image/jpeg": echo "file is jpeg type"; break; case "image/gif": echo "file is gif type"; break; default: echo "file is an image, but not of gif or jpeg type"; } } else { echo "file is not a valid image file"; } ?>
'Server Side > PHP' 카테고리의 다른 글
파라미터 값 $_GET 사용 안하기 (0) | 2016.07.29 |
---|---|
array_shift 사용방법 (0) | 2016.07.29 |
while 문 밖에서 변수 사용 (0) | 2016.01.03 |
PHP 비교 연산자 (0) | 2015.10.17 |
PHP 변수를 쿼리스트링으로 처리할 때 주의사항 (0) | 2015.08.27 |