当前位置:首页 » 多媒体相关

这个路径怎么写啊?


<?  
   
  $filename="image_name";  
   
  //   生成图片的宽度  
  $resizewidth=400;  
   
  //   生成图片的高度  
  $resizeheight=400;  
   
   
  function   resizeimage($im,$maxwidth,$maxheight,$name){  
          $width   =   imagesx($im);  
          $height   =   imagesy($im);  
          if(($maxwidth   &&   $width   >   $maxwidth)   ||   ($maxheight   &&   $height   >   $maxheight)){  
                  if($maxwidth   &&   $width   >   $maxwidth){  
                          $widthratio   =   $maxwidth/$width;  
                          $resizewidth=true;  
                  }  
                  if($maxheight   &&   $height   >   $maxheight){  
                          $heightratio   =   $maxheight/$height;  
                          $resizeheight=true;  
                  }  
                  if($resizewidth   &&   $resizeheight){  
                          if($widthratio   <   $heightratio){  
                                  $ratio   =   $widthratio;  
                          }else{  
                                  $ratio   =   $heightratio;  
                          }  
                  }elseif($resizewidth){  
                          $ratio   =   $widthratio;  
                  }elseif($resizeheight){  
                          $ratio   =   $heightratio;  
                  }  
                  $newwidth   =   $width   *   $ratio;  
                  $newheight   =   $height   *   $ratio;  
                  if(function_exists("imagecopyresampled")){  
                              $newim   =   imagecreatetruecolor($newwidth,   $newheight);  
                              imagecopyresampled($newim,   $im,   0,   0,   0,   0,   $newwidth,   $newheight,   $width,   $height);  
                  }else{  
                          $newim   =   imagecreate($newwidth,   $newheight);  
                              imagecopyresized($newim,   $im,   0,   0,   0,   0,   $newwidth,   $newheight,   $width,   $height);  
                  }  
                  imagejpeg   ($newim,$name   .   ".jpg");  
                  imagedestroy   ($newim);  
          }else{  
                  imagejpeg   ($im,$name   .   ".jpg");  
          }  
  }  
   
   
   
  if($_files[image][size]){  
          if($_files[image][type]   ==   "image/pjpeg"){  
                  $im   =   imagecreatefromjpeg($_files[image][tmp_name]);  
          }elseif($_files[image][type]   ==   "image/x-png"){  
                  $im   =   imagecreatefrompng($_files[image][tmp_name]);  
          }elseif($_files[image][type]   ==   "image/gif"){  
                  $im   =   imagecreatefromgif($_files[image][tmp_name]);  
          }  
          if($im){  
                  if(file_exists("$filename.jpg")){  
                          unlink("$filename.jpg");  
                  }  
                  resizeimage($im,$resizewidth,$resizeheight,$filename);  
                  imagedestroy   ($im);  
          }  
  }  
   
  ?>  
   
  <img   src="<?   echo($filename.".jpg?reload=".rand(0,999999));   ?>"><br><br>  
   
  <form   enctype="multipart/form-data"   method="post">  
  <br>  
  <input   type="file"   name="image"   size="50"   value="浏览"><p>  
  <input   type="submit"   value="上传图片">  
  </form>    
   
  </body>  
  </html>  
  --------------------------------------------------------------------------------  
   
   
  我想上传的图片上传到uploads里,请问,怎么修改啊??  
  $im   =   imagecreatefromjpeg($_files[image][tmp_name],"uploads/");  
  不行啊,报错啊!!  
  大家帮帮忙!!

.

推荐阅读

  • 酷派CoolPAD688和一个职业经理人的一天 [详细内容]
  • 联想T100再降1000仅售4500元 还送1G盘 服务器存储频道 [详细内容]
  • Fujitsu携手SUN制定开放灵活计算新标准 服务器存储频道 [详细内容]
  • 中国IT业一年回眸:职业经理人离职前仆后继 [详细内容]
  • 手机铃声BUG [详细内容]
  • 颠覆传统 3.5英寸硬盘容量剧增至5TB 服务器存储频道 [详细内容]
  • 微软(中国)正成为职业经理人的泥潭 [详细内容]
  • 网友回答:

    讨论区

    Login