사용자가 정적 GIF를 업로드 할 수 있지만 애니메이션을 업로드하지 못하게하고 싶다고 생각합니다. 아바타가 프로페셔널하고 산만 해 보이는 것처럼 말할 수 있습니다. PHP 또는 Zend Framework에서 파일 업로드의 유효성을 검사 할 수있는 방법이 있습니까?파일 업로드 GIF 거부 (PHP/Zend Framework 사용)
3
A
답변
1
0
형성 PHP: imagecreatefromgif - Manual :
I wrote two alternate versions of ZeBadger's is_ani() function, for determining if a gif file is animated
Original:
http://us.php.net/manual/en/function.imagecreatefromgif.php#59787
The first alternative version is just as memory intensive as the original, and more CPU intensive, but far simpler:
<?php
function is_ani($filename) {
return (bool)preg_match('#(\x00\x21\xF9\x04.{4}\x00\x2C.*){2,}#s', file_get_contents($filename));
}
?>
The second alternative is about as CPU intensive as the original function, but uses less memory (and may also result in less disk activity)
<?php
function is_ani($filename) {
if(!($fh = @fopen($filename, 'rb')))
return false;
$count = 0;
//an animated gif contains multiple "frames", with each frame having a
//header made up of:
// * a static 4-byte sequence (\x00\x21\xF9\x04)
// * 4 variable bytes
// * a static 2-byte sequence (\x00\x2C)
// We read through the file til we reach the end of the file, or we've found
// at least 2 frame headers
while(!feof($fh) && $count < 2)
$chunk = fread($fh, 1024 * 100); //read 100kb at a time
$count += preg_match_all('#\x00\x21\xF9\x04.{4}\x00\x2C#s', $chunk, $matches);
fclose($fh);
return $count > 1;
}
?>
관련 문제
- 1. Entity Framework (3.5) - 변경 거부
- 2. Zend framework forms, 파일 업로드 문제
- 3. 브라우저에서 GIF 파일 인쇄
- 4. gif, jpg, png 등을 사용하여 이미지 업로드
- 5. git에서 대용량 파일 거부
- 6. 푸시 된 파일 거부
- 7. 파일 서버에 파일 업로드
- 8. SMF 및 PHP 메모리 사용 파일 업로드
- 9. 세부 정보보기에서 파일 업로드 사용 도움말
- 10. 파일 업로드 및 처리 (Python을 사용)
- 11. ASP.Net에서 콘텐츠 범위 파일 업로드 사용
- 12. Python 파일 업로드 "KeyError"
- 13. 데이터베이스에 파일 업로드
- 14. PHP 파일 업로드
- 15. 파일 업로드 파일
- 16. 사용자 파일 업로드 파일
- 17. 파일 업로드 jquery 플러그인
- 18. 코 테스트 - 파일 업로드
- 19. 업로드 파일
- 20. 파일 업로드
- 21. 파일 업로드
- 22. 파일 업로드
- 23. PHP에서 jqgrid로 파일 업로드
- 24. asp.net에 대한 파일 업로드 C#
- 25. 자바 파일 업로드
- 26. HTTP의 파일 업로드 제한
- 27. 경로를 사용하여 파일 업로드
- 28. 데이터베이스에 파일 업로드 - symfony
- 29. 호스팅 서버에 파일 업로드
- 30. 파일 업로드 오류