Home >Backend Development >PHP Tutorial >缩略图生成的php程序_PHP

缩略图生成的php程序_PHP

WBOY
WBOYOriginal
2016-06-01 12:34:29738browse

客户端上载的页面:

-------------------- 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>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn