developinglife 发表于 2011-12-22 08:54

php上传文件 并 为文件添加水印文字或图片

<DIV>
<DIV id=codeText class=codeText>
<OL style="PADDING-BOTTOM: 5px; MARGIN: 0px 1px 0px 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 5px" class=dp-css>
<LI><SPAN style="COLOR: #000000"><SPAN style="COLOR: #0000cc">&lt;</SPAN><SPAN style="COLOR: #0000cc">?</SPAN><SPAN style="COLOR: #0000ff">php</SPAN><BR></LI>
<LI><SPAN style="COLOR: #ff9900">/******************************************************************************<BR></LI>
<LI><BR></LI>
<LI>参数说明:<BR></LI>
<LI>$max_file_size : 上传文件大小限制, 单位BYTE<BR></LI>
<LI>$destination_folder : 上传文件路径<BR></LI>
<LI>$watermark : 是否附加水印(1为加水印,其他为不加水印);<BR></LI>
<LI><BR></LI>
<LI>使用说明:<BR></LI>
<LI>1. 将PHP.INI文件里面的"extension=php_gd2.dll"一行前面的;号去掉,因为我们要用到GD库;<BR></LI>
<LI>2. 将extension_dir =改为你的php_gd2.dll所在目录;<BR></LI>
<LI>******************************************************************************/</SPAN><BR></LI>
<LI><BR></LI>
<LI><SPAN style="COLOR: #ff9900">//上传文件类型列表<BR></LI>
<LI></SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">uptypes</SPAN><SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff0000">array</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff00ff">'image/jpg'</SPAN><SPAN style="COLOR: #0000cc">,</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff00ff">'image/jpeg'</SPAN><SPAN style="COLOR: #0000cc">,</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff00ff">'image/png'</SPAN><SPAN style="COLOR: #0000cc">,</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff00ff">'image/pjpeg'</SPAN><SPAN style="COLOR: #0000cc">,</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff00ff">'image/gif'</SPAN><SPAN style="COLOR: #0000cc">,</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff00ff">'image/bmp'</SPAN><SPAN style="COLOR: #0000cc">,</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff00ff">'image/x-png'</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><BR></LI>
<LI><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">max_file_size</SPAN><SPAN style="COLOR: #0000cc">=</SPAN>2000000<SPAN style="COLOR: #0000cc">;</SPAN> <SPAN style="COLOR: #ff9900">//大约2M,上传文件大小限制, 单位BYTE<BR></LI>
<LI></SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">destination_folder</SPAN><SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">"uploadimg/"</SPAN><SPAN style="COLOR: #0000cc">;</SPAN> <SPAN style="COLOR: #ff9900">//上传文件路径<BR></LI>
<LI></SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">watermark</SPAN><SPAN style="COLOR: #0000cc">=</SPAN>1<SPAN style="COLOR: #0000cc">;</SPAN> <SPAN style="COLOR: #ff9900">//是否附加水印(1为加水印,其他为不加水印);<BR></LI>
<LI></SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">watertype</SPAN><SPAN style="COLOR: #0000cc">=</SPAN>1<SPAN style="COLOR: #0000cc">;</SPAN> <SPAN style="COLOR: #ff9900">//水印类型(1为文字,2为图片)<BR></LI>
<LI></SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">waterposition</SPAN><SPAN style="COLOR: #0000cc">=</SPAN>1<SPAN style="COLOR: #0000cc">;</SPAN> <SPAN style="COLOR: #ff9900">//水印位置(1为左下角,2为右下角,3为左上角,4为右上角,5为居中);<BR></LI>
<LI></SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">waterstring</SPAN><SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">"JYS studio"</SPAN><SPAN style="COLOR: #0000cc">;</SPAN> <SPAN style="COLOR: #ff9900">//水印字符串<BR></LI>
<LI></SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">waterimg</SPAN><SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">"xplore.gif"</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><SPAN style="COLOR: #ff9900">//水印图片<BR></LI>
<LI></SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">imgpreview</SPAN><SPAN style="COLOR: #0000cc">=</SPAN>1<SPAN style="COLOR: #0000cc">;</SPAN> <SPAN style="COLOR: #ff9900">//是否生成预览图(1为生成,其他为不生成);<BR></LI>
<LI></SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">imgpreviewsize</SPAN><SPAN style="COLOR: #0000cc">=</SPAN>1<SPAN style="COLOR: #0000cc">/</SPAN>2<SPAN style="COLOR: #0000cc">;</SPAN> <SPAN style="COLOR: #ff9900">//缩略图比例<BR></LI>
<LI></SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">?</SPAN><SPAN style="COLOR: #0000cc">&gt;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">&lt;</SPAN><SPAN style="COLOR: #0000ff">html</SPAN><SPAN style="COLOR: #0000cc">&gt;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">&lt;</SPAN><SPAN style="COLOR: #0000ff">head</SPAN><SPAN style="COLOR: #0000cc">&gt;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">&lt;</SPAN><SPAN style="COLOR: #0000ff">title</SPAN><SPAN style="COLOR: #0000cc">&gt;</SPAN>ZwelL图片上传程序<SPAN style="COLOR: #0000cc">&lt;</SPAN><SPAN style="COLOR: #0000cc">/</SPAN><SPAN style="COLOR: #0000ff">title</SPAN><SPAN style="COLOR: #0000cc">&gt;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">&lt;</SPAN><SPAN style="COLOR: #0000ff">style</SPAN> <SPAN style="COLOR: #ff0000">type</SPAN><SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">"text/css"</SPAN><SPAN style="COLOR: #0000cc">&gt;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #ff9900">&lt;!--<BR></LI>
<LI>body<BR></LI>
<LI>{<BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;font-size: 9pt;<BR></LI>
<LI>}<BR></LI>
<LI>input<BR></LI>
<LI>{<BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;background-color: yellow;<BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;border: 1px inset #CCCCCC;<BR></LI>
<LI>}<BR></LI>
<LI>--&gt;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">&lt;</SPAN><SPAN style="COLOR: #0000cc">/</SPAN><SPAN style="COLOR: #0000ff">style</SPAN><SPAN style="COLOR: #0000cc">&gt;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">&lt;</SPAN><SPAN style="COLOR: #0000cc">/</SPAN><SPAN style="COLOR: #0000ff">head</SPAN><SPAN style="COLOR: #0000cc">&gt;</SPAN><BR></LI>
<LI><BR></LI>
<LI><SPAN style="COLOR: #0000cc">&lt;</SPAN><SPAN style="COLOR: #0000ff">body</SPAN><SPAN style="COLOR: #0000cc">&gt;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">&lt;</SPAN><SPAN style="COLOR: #0000ff">form</SPAN> <SPAN style="COLOR: #ff0000">enctype</SPAN><SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">"multipart/form-data"</SPAN> <SPAN style="COLOR: #ff0000">method</SPAN><SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">"post"</SPAN> <SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">"upform"</SPAN><SPAN style="COLOR: #0000cc">&gt;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;上传文件<SPAN style="COLOR: #0000cc">:</SPAN><BR></LI>
<LI>&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">&lt;</SPAN><SPAN style="COLOR: #0000ff">input</SPAN> <SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">"upfile"</SPAN> <SPAN style="COLOR: #ff0000">type</SPAN><SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">"file"</SPAN><SPAN style="COLOR: #0000cc">&gt;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">&lt;</SPAN><SPAN style="COLOR: #0000ff">input</SPAN> <SPAN style="COLOR: #ff0000">type</SPAN><SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">"submit"</SPAN> <SPAN style="COLOR: #ff0000">value</SPAN><SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">"上传"</SPAN><SPAN style="COLOR: #0000cc">&gt;</SPAN><SPAN style="COLOR: #0000cc">&lt;</SPAN><SPAN style="COLOR: #0000ff">br</SPAN><SPAN style="COLOR: #0000cc">&gt;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;允许上传的文件类型为<SPAN style="COLOR: #0000cc">:</SPAN><SPAN style="COLOR: #0000cc">&lt;</SPAN><SPAN style="COLOR: #0000cc">?</SPAN><SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff0000">implode</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #ff00ff">', '</SPAN><SPAN style="COLOR: #0000cc">,</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">uptypes</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">?</SPAN><SPAN style="COLOR: #0000cc">&gt;</SPAN> <SPAN style="COLOR: #ff9900">&lt;!--将uptypes数组中的元素用','链接成字符串返回--&gt;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">&lt;</SPAN><SPAN style="COLOR: #0000cc">/</SPAN><SPAN style="COLOR: #0000ff">form</SPAN><SPAN style="COLOR: #0000cc">&gt;</SPAN><BR></LI>
<LI><BR></LI>
<LI><SPAN style="COLOR: #0000cc">&lt;</SPAN><SPAN style="COLOR: #0000cc">?</SPAN><SPAN style="COLOR: #0000ff">php</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000ff">if</SPAN> <SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">_SERVER</SPAN><SPAN style="COLOR: #0000cc">[</SPAN><SPAN style="COLOR: #ff00ff">'REQUEST_METHOD'</SPAN><SPAN style="COLOR: #0000cc">]</SPAN> <SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #0000cc">=</SPAN> <SPAN style="COLOR: #ff00ff">'POST'</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff9900">//是否存在文件<BR></LI>
<LI></SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">if</SPAN> <SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000cc">!</SPAN><SPAN style="COLOR: #ff0000">is_uploaded_file</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">_FILES</SPAN><SPAN style="COLOR: #0000cc">[</SPAN><SPAN style="COLOR: #ff00ff">"upfile"</SPAN><SPAN style="COLOR: #0000cc">]</SPAN><SPAN style="COLOR: #0000cc">[</SPAN>tmp_name<SPAN style="COLOR: #0000cc">]</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff0000">echo</SPAN> <SPAN style="COLOR: #ff00ff">"图片不存在!"</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff0000">exit</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">}</SPAN><BR></LI>
<LI><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">file</SPAN> <SPAN style="COLOR: #0000cc">=</SPAN> <SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">_FILES</SPAN><SPAN style="COLOR: #0000cc">[</SPAN><SPAN style="COLOR: #ff00ff">"upfile"</SPAN><SPAN style="COLOR: #0000cc">]</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff9900">//检查文件大小<BR></LI>
<LI></SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">max_file_size</SPAN> <SPAN style="COLOR: #0000cc">&lt;</SPAN> <SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">file</SPAN><SPAN style="COLOR: #0000cc">[</SPAN><SPAN style="COLOR: #ff00ff">"size"</SPAN><SPAN style="COLOR: #0000cc">]</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff0000">echo</SPAN> <SPAN style="COLOR: #ff00ff">"文件太大!不能超过2M!"</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff0000">exit</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">}</SPAN><BR></LI>
<LI><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff9900">//检查文件类型<BR></LI>
<LI></SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000cc">!</SPAN><SPAN style="COLOR: #ff0000">in_array</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">file</SPAN><SPAN style="COLOR: #0000cc">[</SPAN><SPAN style="COLOR: #ff00ff">"type"</SPAN><SPAN style="COLOR: #0000cc">]</SPAN><SPAN style="COLOR: #0000cc">,</SPAN> <SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">uptypes</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff0000">echo</SPAN> <SPAN style="COLOR: #ff00ff">"文件类型不符!"</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">file</SPAN><SPAN style="COLOR: #0000cc">[</SPAN><SPAN style="COLOR: #ff00ff">"type"</SPAN><SPAN style="COLOR: #0000cc">]</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff0000">exit</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">}</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff9900">//上传到的文件夹不存在则自动创建<BR></LI>
<LI></SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000cc">!</SPAN><SPAN style="COLOR: #ff0000">file_exists</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">destination_folder</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff0000">mkdir</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">destination_folder</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">}</SPAN><BR></LI>
<LI><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">filename</SPAN><SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">file</SPAN><SPAN style="COLOR: #0000cc">[</SPAN><SPAN style="COLOR: #ff00ff">"tmp_name"</SPAN><SPAN style="COLOR: #0000cc">]</SPAN><SPAN style="COLOR: #0000cc">;</SPAN> <SPAN style="COLOR: #ff9900">//系统自动生成的临时文件名<BR></LI>
<LI></SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">filenamecustom</SPAN> <SPAN style="COLOR: #0000cc">=</SPAN> <SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">file</SPAN><SPAN style="COLOR: #0000cc">[</SPAN><SPAN style="COLOR: #ff00ff">"name"</SPAN><SPAN style="COLOR: #0000cc">]</SPAN><SPAN style="COLOR: #0000cc">;</SPAN> <SPAN style="COLOR: #ff9900">//用户上传的文件名<BR></LI>
<LI></SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">image_size</SPAN> <SPAN style="COLOR: #0000cc">=</SPAN> <SPAN style="COLOR: #ff0000">getimagesize</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">filename</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN> <SPAN style="COLOR: #ff9900">//图像大小<BR></LI>
<LI></SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">pinfo</SPAN><SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff0000">pathinfo</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">file</SPAN><SPAN style="COLOR: #0000cc">[</SPAN><SPAN style="COLOR: #ff00ff">"name"</SPAN><SPAN style="COLOR: #0000cc">]</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN> <SPAN style="COLOR: #ff9900">//上传文件的路径信息<BR></LI>
<LI></SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">ftype</SPAN><SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">pinfo</SPAN><SPAN style="COLOR: #0000cc">[</SPAN><SPAN style="COLOR: #ff00ff">'extension'</SPAN><SPAN style="COLOR: #0000cc">]</SPAN><SPAN style="COLOR: #0000cc">;</SPAN> <SPAN style="COLOR: #ff9900">//上传文件的扩展名<BR></LI>
<LI></SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff9900">//$destination = $destination_folder.time().".".$ftype;//上传文件的目录+文件名+文件类型,文件名由time()生成<BR></LI>
<LI></SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">destination</SPAN> <SPAN style="COLOR: #0000cc">=</SPAN> <SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">destination_folder</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">filenamecustom</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff00ff">"."</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">ftype</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><SPAN style="COLOR: #ff9900">//上传文件的目录+用户文件名+文件类型<BR></LI>
<LI></SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff9900">//检查同名文件是否存在<BR></LI>
<LI></SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">if</SPAN> <SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #ff0000">file_exists</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">destination</SPAN><SPAN style="COLOR: #0000cc">)</SPAN> <SPAN style="COLOR: #0000cc">&amp;</SPAN><SPAN style="COLOR: #0000cc">&amp;</SPAN> <SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">overwrite</SPAN> <SPAN style="COLOR: #0000cc">!</SPAN><SPAN style="COLOR: #0000cc">=</SPAN> <SPAN style="COLOR: #0000ff">true</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff0000">echo</SPAN> <SPAN style="COLOR: #ff00ff">"同名文件已经存在了"</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff0000">exit</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">}</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff9900">//移动文件到指定目录<BR></LI>
<LI></SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000cc">!</SPAN><SPAN style="COLOR: #ff0000">move_uploaded_file</SPAN> <SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">filename</SPAN><SPAN style="COLOR: #0000cc">,</SPAN> <SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">destination</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff0000">echo</SPAN> <SPAN style="COLOR: #ff00ff">"移动文件出错"</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff0000">exit</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">}</SPAN><BR></LI>
<LI><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">pinfo</SPAN><SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff0000">pathinfo</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">destination</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN> <SPAN style="COLOR: #ff9900">//上传到服务器上的文件的路径信息<BR></LI>
<LI></SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">fname</SPAN><SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">pinfo</SPAN><SPAN style="COLOR: #0000cc">[</SPAN><SPAN style="COLOR: #ff0000">basename</SPAN><SPAN style="COLOR: #0000cc">]</SPAN><SPAN style="COLOR: #0000cc">;</SPAN> <SPAN style="COLOR: #ff9900">//上传到服务器上的文件名<BR></LI>
<LI></SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff9900">// echo " &lt;font color=red&gt;已经成功上传!&lt;/font&gt;&lt;br&gt;文件名: &lt;font color=blue&gt;".$destination_folder.$fname."&lt;/font&gt;&lt;br&gt;";<BR></LI>
<LI></SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff9900">// echo " &lt;font color=red&gt;已经成功上传!&lt;/font&gt;&lt;br&gt;文件名: &lt;font color=blue&gt;".$destination."&lt;/font&gt;&lt;br&gt;";<BR></LI>
<LI></SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff0000">echo</SPAN> <SPAN style="COLOR: #ff00ff">" &lt;font color=red&gt;已经成功上传!&lt;/font&gt;&lt;br&gt;文件名: &lt;font color=blue&gt;"</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">destination_folder</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">filenamecustom</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff00ff">"&lt;/font&gt;&lt;br&gt;"</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff0000">echo</SPAN> <SPAN style="COLOR: #ff00ff">" 宽度:"</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">image_size</SPAN><SPAN style="COLOR: #0000cc">[</SPAN>0<SPAN style="COLOR: #0000cc">]</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff0000">echo</SPAN> <SPAN style="COLOR: #ff00ff">" 长度:"</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">image_size</SPAN><SPAN style="COLOR: #0000cc">[</SPAN>1<SPAN style="COLOR: #0000cc">]</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff0000">echo</SPAN> <SPAN style="COLOR: #ff00ff">"&lt;br&gt; 大小:"</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">file</SPAN><SPAN style="COLOR: #0000cc">[</SPAN><SPAN style="COLOR: #ff00ff">"size"</SPAN><SPAN style="COLOR: #0000cc">]</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff00ff">" bytes"</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">watermark</SPAN><SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #0000cc">=</SPAN>1<SPAN style="COLOR: #0000cc">)</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">iinfo</SPAN><SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff0000">getimagesize</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">destination</SPAN><SPAN style="COLOR: #0000cc">,</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">iinfo</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN> <SPAN style="COLOR: #ff9900">//取得图像大小、类型<BR></LI>
<LI></SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">nimage</SPAN><SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff0000">imagecreatetruecolor</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">image_size</SPAN><SPAN style="COLOR: #0000cc">[</SPAN>0<SPAN style="COLOR: #0000cc">]</SPAN><SPAN style="COLOR: #0000cc">,</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">image_size</SPAN><SPAN style="COLOR: #0000cc">[</SPAN>1<SPAN style="COLOR: #0000cc">]</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN> <SPAN style="COLOR: #ff9900">//新建一个真彩色图像,返回一个图像标识符,<BR></LI>
<LI></SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff9900">//代表了一幅大小为 x_size 和 y_size 的黑色图像。 <BR></LI>
<LI></SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">white</SPAN><SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff0000">imagecolorallocate</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">nimage</SPAN><SPAN style="COLOR: #0000cc">,</SPAN>255<SPAN style="COLOR: #0000cc">,</SPAN>255<SPAN style="COLOR: #0000cc">,</SPAN>255<SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN> <SPAN style="COLOR: #ff9900">//nimage分配颜色<BR></LI>
<LI></SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">black</SPAN><SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff0000">imagecolorallocate</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">nimage</SPAN><SPAN style="COLOR: #0000cc">,</SPAN>0<SPAN style="COLOR: #0000cc">,</SPAN>0<SPAN style="COLOR: #0000cc">,</SPAN>0<SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">red</SPAN><SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff0000">imagecolorallocate</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">nimage</SPAN><SPAN style="COLOR: #0000cc">,</SPAN>255<SPAN style="COLOR: #0000cc">,</SPAN>0<SPAN style="COLOR: #0000cc">,</SPAN>0<SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff0000">imagefill</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">nimage</SPAN><SPAN style="COLOR: #0000cc">,</SPAN>0<SPAN style="COLOR: #0000cc">,</SPAN>0<SPAN style="COLOR: #0000cc">,</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">white</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN> <SPAN style="COLOR: #ff9900">//在 nimage 图像的坐标 x,y(图像左上角为 0, 0)处用 color 颜色执行区域填充<BR></LI>
<LI></SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff9900">//(即与 x, y 点颜色相同且相邻的点都会被填充)。<BR></LI>
<LI></SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff9900">/*<BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;1 = GIF,2 = JPG,3 = PNG,4 = SWF,5 = PSD,6 = BMP,7 = TIFF(intel byte order),8 = TIFF(motorola byte order),<BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;9 = JPC,10 = JP2,11 = JPX,12 = JB2,13 = SWC,14 = IFF,15 = WBMP,16 = XBM<BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;*/</SPAN> <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">switch</SPAN> <SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">iinfo</SPAN><SPAN style="COLOR: #0000cc">[</SPAN>2<SPAN style="COLOR: #0000cc">]</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">case</SPAN> 1<SPAN style="COLOR: #0000cc">:</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">simage</SPAN> <SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff0000">imagecreatefromgif</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">destination</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN> <SPAN style="COLOR: #ff9900">//从给定的文件名取得的图像<BR></LI>
<LI></SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">break</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">case</SPAN> 2<SPAN style="COLOR: #0000cc">:</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">simage</SPAN> <SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff0000">imagecreatefromjpeg</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">destination</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">break</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">case</SPAN> 3<SPAN style="COLOR: #0000cc">:</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">simage</SPAN> <SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff0000">imagecreatefrompng</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">destination</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">break</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">case</SPAN> 6<SPAN style="COLOR: #0000cc">:</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">simage</SPAN> <SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff0000">imagecreatefromwbmp</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">destination</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">break</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">default</SPAN><SPAN style="COLOR: #0000cc">:</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff0000">die</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #ff00ff">"不支持的文件类型"</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN> <SPAN style="COLOR: #ff9900">//Equivalent to exit()<BR></LI>
<LI></SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff0000">exit</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">}</SPAN><BR></LI>
<LI><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff0000">imagecopy</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">nimage</SPAN><SPAN style="COLOR: #0000cc">,</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">simage</SPAN><SPAN style="COLOR: #0000cc">,</SPAN>0<SPAN style="COLOR: #0000cc">,</SPAN>0<SPAN style="COLOR: #0000cc">,</SPAN>0<SPAN style="COLOR: #0000cc">,</SPAN>0<SPAN style="COLOR: #0000cc">,</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">image_size</SPAN><SPAN style="COLOR: #0000cc">[</SPAN>0<SPAN style="COLOR: #0000cc">]</SPAN><SPAN style="COLOR: #0000cc">,</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">image_size</SPAN><SPAN style="COLOR: #0000cc">[</SPAN>1<SPAN style="COLOR: #0000cc">]</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><SPAN style="COLOR: #ff9900">//将simage从0,0开始,$image_size宽、$image_size高<BR></LI>
<LI></SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff9900">//的一部分拷贝到nimage中坐标为0,0的位置上<BR></LI>
<LI></SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff0000">imagefilledrectangle</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">nimage</SPAN><SPAN style="COLOR: #0000cc">,</SPAN>1<SPAN style="COLOR: #0000cc">,</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">image_size</SPAN><SPAN style="COLOR: #0000cc">[</SPAN>1<SPAN style="COLOR: #0000cc">]</SPAN><SPAN style="COLOR: #0000cc">-</SPAN>15<SPAN style="COLOR: #0000cc">,</SPAN>80<SPAN style="COLOR: #0000cc">,</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">image_size</SPAN><SPAN style="COLOR: #0000cc">[</SPAN>1<SPAN style="COLOR: #0000cc">]</SPAN><SPAN style="COLOR: #0000cc">,</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">white</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><SPAN style="COLOR: #ff9900">//在nimage 图像中用white颜色画一个左上角坐标为1,$image_size-15<BR></LI>
<LI></SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff9900">//右下角坐标为80,$image_size的矩形<BR></LI>
<LI></SPAN><BR></LI>
<LI><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">switch</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">watertype</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">case</SPAN> 1<SPAN style="COLOR: #0000cc">:</SPAN> <SPAN style="COLOR: #ff9900">//加水印字符串<BR></LI>
<LI></SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff0000">imagestring</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">nimage</SPAN><SPAN style="COLOR: #0000cc">,</SPAN>2<SPAN style="COLOR: #0000cc">,</SPAN>3<SPAN style="COLOR: #0000cc">,</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">image_size</SPAN><SPAN style="COLOR: #0000cc">[</SPAN>1<SPAN style="COLOR: #0000cc">]</SPAN><SPAN style="COLOR: #0000cc">-</SPAN>15<SPAN style="COLOR: #0000cc">,</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">waterstring</SPAN><SPAN style="COLOR: #0000cc">,</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">black</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><SPAN style="COLOR: #ff9900">//用黑色将waterstring画到nimage的3,$image_size-15坐标处,字体为内置字体2<BR></LI>
<LI></SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">break</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">case</SPAN> 2<SPAN style="COLOR: #0000cc">:</SPAN> <SPAN style="COLOR: #ff9900">//加水印图片<BR></LI>
<LI></SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">simage1</SPAN> <SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff0000">imagecreatefromgif</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #ff00ff">"xplore.gif"</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff0000">imagecopy</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">nimage</SPAN><SPAN style="COLOR: #0000cc">,</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">simage1</SPAN><SPAN style="COLOR: #0000cc">,</SPAN>0<SPAN style="COLOR: #0000cc">,</SPAN>0<SPAN style="COLOR: #0000cc">,</SPAN>0<SPAN style="COLOR: #0000cc">,</SPAN>0<SPAN style="COLOR: #0000cc">,</SPAN>85<SPAN style="COLOR: #0000cc">,</SPAN>15<SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff0000">imagedestroy</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">simage1</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN> <SPAN style="COLOR: #ff9900">//释放与 simagel 关联的内存<BR></LI>
<LI></SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">break</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">}</SPAN><BR></LI>
<LI><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">switch</SPAN> <SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">iinfo</SPAN><SPAN style="COLOR: #0000cc">[</SPAN>2<SPAN style="COLOR: #0000cc">]</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">case</SPAN> 1<SPAN style="COLOR: #0000cc">:</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff9900">//imagegif($nimage, $destination);<BR></LI>
<LI></SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff0000">imagejpeg</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">nimage</SPAN><SPAN style="COLOR: #0000cc">,</SPAN> <SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">destination</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN> <SPAN style="COLOR: #ff9900">//从 nimage 图像以 destination 为文件名创建一个 JPEG 图像。nimage 参数是 imagecreatetruecolor() 函数的返回值。<BR></LI>
<LI></SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">break</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">case</SPAN> 2<SPAN style="COLOR: #0000cc">:</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff0000">imagejpeg</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">nimage</SPAN><SPAN style="COLOR: #0000cc">,</SPAN> <SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">destination</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">break</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">case</SPAN> 3<SPAN style="COLOR: #0000cc">:</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff0000">imagepng</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">nimage</SPAN><SPAN style="COLOR: #0000cc">,</SPAN> <SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">destination</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">break</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">case</SPAN> 6<SPAN style="COLOR: #0000cc">:</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff0000">imagewbmp</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">nimage</SPAN><SPAN style="COLOR: #0000cc">,</SPAN> <SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">destination</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff9900">//imagejpeg($nimage, $destination);<BR></LI>
<LI></SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">break</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">}</SPAN><BR></LI>
<LI><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff9900">//释放内存<BR></LI>
<LI></SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff0000">imagedestroy</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">nimage</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff0000">imagedestroy</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">simage</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">}</SPAN><BR></LI>
<LI><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">imgpreview</SPAN><SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #0000cc">=</SPAN>1<SPAN style="COLOR: #0000cc">)</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff0000">echo</SPAN> <SPAN style="COLOR: #ff00ff">"&lt;br&gt;图片预览:&lt;br&gt;"</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff0000">echo</SPAN> <SPAN style="COLOR: #ff00ff">"&lt;img src=\""</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">destination</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff00ff">"\" width="</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">image_size</SPAN><SPAN style="COLOR: #0000cc">[</SPAN>0<SPAN style="COLOR: #0000cc">]</SPAN><SPAN style="COLOR: #0000cc">*</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">imgpreviewsize</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff00ff">" height="</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">image_size</SPAN><SPAN style="COLOR: #0000cc">[</SPAN>1<SPAN style="COLOR: #0000cc">]</SPAN><SPAN style="COLOR: #0000cc">*</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">imgpreviewsize</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff0000">echo</SPAN> <SPAN style="COLOR: #ff00ff">" alt=\"图片预览:\r文件名:"</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #0000ff">$</SPAN><SPAN style="COLOR: #008080">destination</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff00ff">"\r上传时间:\"&gt;"</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">}</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">}</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">?</SPAN><SPAN style="COLOR: #0000cc">&gt;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">&lt;</SPAN><SPAN style="COLOR: #0000cc">/</SPAN><SPAN style="COLOR: #0000ff">body</SPAN><SPAN style="COLOR: #0000cc">&gt;</SPAN></SPAN></LI></OL></DIV></DIV>
页: [1]
查看完整版本: php上传文件 并 为文件添加水印文字或图片