> 백엔드 개발 > PHP 튜토리얼 > 缩略图生成的php程序_PHP

缩略图生成的php程序_PHP

WBOY
풀어 주다: 2016-06-01 12:34:29
원래의
734명이 탐색했습니다.

客户端上载的页面:

-------------------- upload.htm ---------------------


method="post" action="upload.php">

请选择或输入上传文件名:



--------------------- upload.php -------------------

<font color="#000000"> <font color="#0000BB"></font><font color="#007700"> <br>if(empty(</font><font color="#0000BB">$upfile</font><font color="#007700">)){ <br><br>print(</font><font color="#DD0000">"No file was transfered!\n无文件上传!"</font><font color="#007700">); <br><br>exit; <br><br>} <br><br></font><font color="#0000BB">$image_path</font><font color="#007700">=</font><font color="#0000BB">$upfile</font><font color="#007700">; <br><br>@</font><font color="#0000BB">$image_info</font><font color="#007700">=</font><font color="#0000BB">getimagesize</font><font color="#007700">(</font><font color="#0000BB">$image_path</font><font color="#007700">); <br><br>if(</font><font color="#0000BB">$image_info</font><font color="#007700">[</font><font color="#0000BB">2</font><font color="#007700">]==</font><font color="#0000BB">2</font><font color="#007700">) <br><br>{@</font><font color="#0000BB">$image2</font><font color="#007700">=</font><font color="#0000BB">imagecreatefromjpeg</font><font color="#007700">(</font><font color="#0000BB">$image_path</font><font color="#007700">); <br><br>} <br><br>else if(</font><font color="#0000BB">$image_info</font><font color="#007700">[</font><font color="#0000BB">2</font><font color="#007700">]==</font><font color="#0000BB">1</font><font color="#007700">){ <br><br>@</font><font color="#0000BB">$image2</font><font color="#007700">=</font><font color="#0000BB">imagecreatefromgif</font><font color="#007700">(</font><font color="#0000BB">$image_path</font><font color="#007700">); <br><br>} <br><br>else <br><br>if(empty(</font><font color="#0000BB">$image2</font><font color="#007700">)) <br><br></font><font color="#0000BB">$image2_x</font><font color="#007700">=</font><font color="#0000BB">imagesx</font><font color="#007700">(</font><font color="#0000BB">$image2</font><font color="#007700">); <br><br></font><font color="#0000BB">$image2_y</font><font color="#007700">=</font><font color="#0000BB">imagesy</font><font color="#007700">(</font><font color="#0000BB">$image2</font><font color="#007700">); <br><br>if(</font><font color="#0000BB">$image2_x</font><font color="#007700">==</font><font color="#0000BB">$image2_y</font><font color="#007700">){ <br><br></font><font color="#0000BB">$x</font><font color="#007700">=</font><font color="#0000BB">150</font><font color="#007700">; <br><br></font><font color="#0000BB">$y</font><font color="#007700">=</font><font color="#0000BB">0</font><font color="#007700">; <br><br>} <br><br>else if(</font><font color="#0000BB">$image2_x</font><font color="#007700">></font><font color="#0000BB">$image2_y</font><font color="#007700">){ <br><br></font><font color="#0000BB">$x</font><font color="#007700">=</font><font color="#0000BB">150</font><font color="#007700">; <br><br></font><font color="#0000BB">$y</font><font color="#007700">=</font><font color="#0000BB">intval</font><font color="#007700">(</font><font color="#0000BB">150</font><font color="#007700">*</font><font color="#0000BB">$image2_y</font><font color="#007700">/</font><font color="#0000BB">$image2_x</font><font color="#007700">); <br><br>} <br><br>else{ <br><br></font><font color="#0000BB">$y</font><font color="#007700">=</font><font color="#0000BB">150</font><font color="#007700">; <br><br></font><font color="#0000BB">$x</font><font color="#007700">=</font><font color="#0000BB">intval</font><font color="#007700">(</font><font color="#0000BB">150</font><font color="#007700">*</font><font color="#0000BB">$image2_x</font><font color="#007700">/</font><font color="#0000BB">$image2_y</font><font color="#007700">); <br><br>} <br><br></font><font color="#0000BB">$image1</font><font color="#007700">=</font><font color="#0000BB">imagecreate</font><font color="#007700">(</font><font color="#0000BB">$x</font><font color="#007700">,</font><font color="#0000BB">$y</font><font color="#007700">); <br><br></font><font color="#0000BB">imagecopyresized</font><font color="#007700">(</font><font color="#0000BB">$image1</font><font color="#007700">,</font><font color="#0000BB">$image2</font><font color="#007700">,</font><font color="#0000BB">0</font><font color="#007700">,</font><font color="#0000BB">0</font><font color="#007700">,</font><font color="#0000BB">0</font><font color="#007700">,</font><font color="#0000BB">0</font><font color="#007700">,</font><font color="#0000BB">$x</font><font color="#007700">,</font><font color="#0000BB">$y</font><font color="#007700">,</font><font color="#0000BB">$image2_x</font><font color="#007700">,</font><font color="#0000BB">$image2_y</font><font color="#007700">); <br><br></font><font color="#0000BB">imagegif</font><font color="#007700">(</font><font color="#0000BB">$image1</font><font color="#007700">,</font><font color="#DD0000">"new.gif"</font><font color="#007700">); <br><br></font><font color="#0000BB">?></font></font>
관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿