php编写功能强大上传图片的类(2)
来源:未知 责任编辑:责任编辑 发表时间:2013-11-17 14:39 点击:次
$this->showerror("上传图片类型错误"); } } //上传图片 function up_photo(){ if(!move_uploaded_file($this->ph_tmp_name,$this->ph_name)){ $this->showerror("上传文件出错"); } } //图片预览 function showphoto(){ if($this->preview==1){ if($this->imgsize[0]>2000){ $this->imgsize[0]=$this->imgsize[0]*$this->previewsize; $this->imgsize[1]=$this->imgsize[1]*$this->previewsize; } echo("<img src="{$this->ph_name}" width="{$this->imgsize[0]}" height="{$this->imgsize[1]}">"); } } //错误提示 function showerror($errorstr){ echo "<script language=javascript>alert($errorstr);location=javascript:history.go(-1);;</script>"; exit(); } function save(){ $this->check_path(); $this->check_size(); $this->check_type(); $this->up_photo(); $this->showphoto(); } } ?>