예제 #1
0
파일: newsEdit.php 프로젝트: btbj/wechat
 private function uploadImg()
 {
     if (isset($_POST['upfile']) || $_FILES['upfile']) {
         header("Content-Type:text/html;charset=utf-8");
         error_reporting(E_ERROR | E_WARNING);
         $config = array("savePath" => imgPath, "maxSize" => maxSize, "allowFiles" => array(".gif", ".png", ".jpg", ".jpeg", ".bmp"));
         $up = new uploader($_SESSION['weixinId'], $this->newsId, "upfile", $config);
         $type = $_REQUEST['type'];
         $callback = $_GET['callback'];
         $info = $up->getFileInfo();
         wxlog(json_encode($info));
         /**
          * 返回数据
          */
         if ($callback) {
             echo '<script>' . $callback . '(' . json_encode($info) . ')</script>';
         } else {
             echo json_encode($info);
         }
     }
 }
예제 #2
0
     mylog('frontUp');
     $inf = $uploader->getFileInfo();
     if ('SUCCESS' == $inf['state']) {
         $id = pdoInsert('ad_tbl', array('category' => 'banner', 'img_url' => $inf['url']), '');
         $inf['id'] = $id;
     }
     //        header('contentType:application/json');
     $jsonInf = json_encode($inf, JSON_UNESCAPED_UNICODE);
     mylog('imgUploaded:' . $jsonInf);
     echo $jsonInf;
     exit;
 }
 if (isset($_FILES['parts-img-up'])) {
     $uploader = new uploader('parts-img-up');
     $uploader->upFile($_GET['g_id'] . '_' . time() . rand(1000, 9999));
     $inf = $uploader->getFileInfo();
     $jsonInf = json_encode($inf, JSON_UNESCAPED_UNICODE);
     if ('SUCCESS' == $inf['state']) {
         mylog('success');
         $temp = pdoQuery('g_image_tbl', null, array('g_id' => $_GET['g_id']), 'limit 1');
         if (!($row = $temp->fetch())) {
             pdoInsert('g_image_tbl', array('g_id' => $_GET['g_id'], 'url' => $inf['url'], 'remark' => $inf['md5']), 'ignore');
             mylog("create record");
         } else {
             pdoUpdate('g_image_tbl', array('remark' => $inf['md5'], 'url' => $inf['url']), array('g_id' => $_GET['g_id']));
             $query = pdoQuery('image_view', null, array('remark' => $row['remark']), ' limit 1');
             if (!($t = $query->fetch())) {
                 unlink('../' . $row['url']);
                 mylog('unlink"../' . $row['url']);
             } else {
                 mylog('not unlink');
예제 #3
0
 * Time: 15:23
 */
header("Content-Type:text/html;charset=utf-8");
error_reporting(E_ERROR | E_WARNING);
$mypath = $_SERVER['DOCUMENT_ROOT'] . '/wechat';
include_once $mypath . '/includes/magicquotes.inc.php';
include_once $mypath . '/includes/db.inc.php';
include_once $mypath . '/includes/helpers.inc.php';
include_once $mypath . '/class/uploader.php';
session_start();
//上传配置
$config = array("savePath" => "../user_img", "maxSize" => 1000, "allowFiles" => array(".gif", ".png", ".jpg", ".jpeg", ".bmp"));
//上传文件目录
//$Path = "upload/";
//背景保存在临时目录中
//$config[ "savePath" ] = $Path;
if (!isset($_SESSION['temp_name'])) {
    $_SESSION['temp_name'] = getRandStr();
}
$up = new uploader($_SESSION['weixinId'], $_SESSION['temp_name'], "upfile", $config);
$type = $_REQUEST['type'];
$callback = $_GET['callback'];
$info = $up->getFileInfo();
/**
 * 返回数据
 */
if ($callback) {
    echo '<script>' . $callback . '(' . json_encode($info) . ')</script>';
} else {
    echo json_encode($info);
}
예제 #4
0
파일: ueditor.php 프로젝트: JavaBird/mysite
 public function upload()
 {
     /* 上传配置 */
     $base64 = "upload";
     switch (htmlspecialchars($_GET['action'])) {
         case 'uploadimage':
             $config = array("pathFormat" => $CONFIG['imagePathFormat'], "maxSize" => $CONFIG['imageMaxSize'], "allowFiles" => $CONFIG['imageAllowFiles']);
             $fieldName = $CONFIG['imageFieldName'];
             break;
         case 'uploadscrawl':
             $config = array("pathFormat" => $CONFIG['scrawlPathFormat'], "maxSize" => $CONFIG['scrawlMaxSize'], "allowFiles" => $CONFIG['scrawlAllowFiles'], "oriName" => "scrawl.png");
             $fieldName = $CONFIG['scrawlFieldName'];
             $base64 = "base64";
             break;
         case 'uploadvideo':
             $config = array("pathFormat" => $CONFIG['videoPathFormat'], "maxSize" => $CONFIG['videoMaxSize'], "allowFiles" => $CONFIG['videoAllowFiles']);
             $fieldName = $CONFIG['videoFieldName'];
             break;
         case 'uploadfile':
         default:
             $config = array("pathFormat" => $CONFIG['filePathFormat'], "maxSize" => $CONFIG['fileMaxSize'], "allowFiles" => $CONFIG['fileAllowFiles']);
             $fieldName = $CONFIG['fileFieldName'];
             break;
     }
     /* 生成上传实例对象并完成上传 */
     $up = new uploader($fieldName, $config, $base64);
     /**
      * 得到上传文件所对应的各个参数,数组结构
      * array(
      *     "state" => "",          //上传状态,上传成功时必须返回"SUCCESS"
      *     "url" => "",            //返回的地址
      *     "title" => "",          //新文件名
      *     "original" => "",       //原始文件名
      *     "type" => ""            //文件类型
      *     "size" => "",           //文件大小
      * )
      */
     /* 返回数据 */
     return json_encode($up->getFileInfo());
 }