<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
 $("#images").change(function(){
   $("#form1").submit();
 });
});function stopSend(str){
 var im="<img src='uploads/"+str+"' width='200' height='200'>";
 $("#msg").append(im);
}
</script>
<body>
<form action="imgclass.php" id="form1" name="form1" enctype="multipart/form-data" method="post" target="uploadIframe">
        <input type="file" id="images" name="images"/>
</form>
<iframe name="uploadIframe" id="uploadIframe" style="display:none"></iframe>
<!--<p><span id="txtHint"></span></p> -->
 <div id="msg"></div>
</body>
</html>
<?php
class UpImages{


var $img_z;  //图片大小
var $img_h; //图片高度
var $img_w;  //图片宽度
var $upFileType = "jpg gif png";    //上传类型
var $upFileLoad; //上传图片路径
var $FileLoad  ;  //上传水印路径
var $smallFileLoad  ;  //上传缩略图路径
var $fontType; //文字类型
var $upFileMax = 1024; //上传大小限制,单位是“KB”,默认为:1024KB

function UpImages($upFileLoad,$smallFileLoad,$fontincludeLoad){

$this->upFileLoad = $upFileLoad;

$this->smallFileLoad = $smallFileLoad;

$this->fontType = $fontincludeLoad."/04B_08__.TTF"; echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">";

}

function UpLoad($inputname){
$imgname = time();
if(@empty($_FILES[$inputname]["name"]))die("<script type='text/javascript'>alert('没有上传图片信息,请确认')</script>");
$name = explode(".",$_FILES[$inputname]["name"]);
$imgCont = count($name);
$imgType = $name[$imgCont-1];
if(strpos($this->upFileType,$imgType) === false) die("<script type='text/javascript'>alert('上传类型只支持".$this->upFileType."不支持".$imgType."')</script>");
$photo = $imgname.".".$imgType;
$upLoad = $this->upFileLoad.$photo;
//echo $upLoad;
$upFileok = move_uploaded_file($_FILES[$inputname]["tmp_name"],$upLoad);
if($upFileok){
$imgSize = $_FILES[$inputname]['size'];
//echo $imgSize;
$kSize = round($imgSize/1024);
if($kSize > $this->upFileMax){
unlink($upLoad);
die("<script type='text/javascript'>alert('上传文件超过".$this->upFileMax."KB')</script>");
}
}else{
die("<script type='text/javascript'>alert('上传图片失败,请确认你的上传文件不超过 ".$this->upFileMax."KB 或上传时间超时')</script>");
}
//echo $this->upFileLoad;
//echo $photo;
return $photo;
}
}
 $upfile = "uploads/";
 $upload = new UpImages($upfile,$upfile,$upfile);
 $imgfile = $upload->UpLoad("images");
  echo "<script>parent.stopSend('$imgfile')</script>";
  
 ?>