Sin Descripción

upload.php 1.6KB

    <?php header("Content-type: text/html; charset=utf-8"); $maxSize = 1024 * 1024 * 2; //1M 设置附件上传大小 $allowExts = array("gif", "jpg", "jpeg", "png"); // 设置附件上传类型 include_once("UploadFile.class.php"); $upload = new UploadFile(); // 实例化上传类 $upload->maxSize = $maxSize; $upload->allowExts = $allowExts; $upload->savePath = '../data/pic/'; // 设置附件 $upload->saveRule = time() . sprintf('%04s', mt_rand(0, 1000)); if (!$upload->upload()) {// 上传错误提示错误信息 header ('Content-type: text/html; charset=utf-8' ); echo "<script>alert('上传图片信息失败,请重新上传!');javascript :history.back(-1);</script>";exit; } else {// 上传成功 获取上传文件信息 $info = $upload->getUploadFileInfo(); $imgurl = $info[0]['savename']; $arr = explode(" x ",$_POST['filedim']); if($_POST['w'] == '' && $_POST['h'] == ''){ header ('Content-type: text/html; charset=utf-8' ); echo "<script>location.href='/msg/doavatars.html?pic=".$imgurl."'</script>";exit; }else{ $x = ceil($_POST['x1'] * ($arr[0] / 330)); $y = ceil($_POST['y1'] * ($arr[1] / 330)); $x2 = $_POST['x2']; $y2 = $_POST['y2']; $w = ceil($_POST['w']*($arr[0] / 330)); $h = ceil($_POST['h']*($arr[0] / 330)); include_once("jcrop_image.class.php"); $filep = "../data/pic/"; $pic_name = $filep . $imgurl; $crop = new jcrop_image($filep, $pic_name, $x, $y, $w, $h, $w, $h); $file = $crop->crop(); header ('Content-type: text/html; charset=utf-8' ); echo "<script>location.href='/msg/doavatars.html?pic=".$file."'</script>";exit; } } ?>