示例#1
0
 } else {
     // อัปโหลดรูปภาw
     if ($file['tmp_name'] != '') {
         // ตรวจสอบไฟล์อัปโหลด
         $info = gcms::isValidImage($config['gallery_image_type'], $file);
         if (!$info) {
             $ret['ret_gallery_pic'] = 'INVALID_FILE_TYPE';
             $input = 'gallery_pic';
             $error = 'INVALID_FILE_TYPE';
         } elseif (!gcms::testDir(DATA_PATH . "gallery/{$index['id']}/")) {
             $ret['ret_gallery_pic'] = 'DO_NOT_UPLOAD';
             $input = 'gallery_pic';
             $error = 'DO_NOT_UPLOAD';
         } else {
             // อัปโหลดรูปภาพจริง
             $res = gcms::resizeImage($file['tmp_name'], DATA_PATH . "gallery/{$index['id']}/", "0.{$info['ext']}", $info, $config['gallery_image_w']);
             if (!$res) {
                 $ret['ret_gallery_pic'] = 'DO_NOT_UPLOAD';
                 $input = 'gallery_pic';
                 $error = 'DO_NOT_UPLOAD';
             } else {
                 $save2['image'] = $res['name'];
             }
             // อัปโหลด thumbnail
             if (!gcms::cropImage($file['tmp_name'], DATA_PATH . "gallery/{$index['id']}/thumb_{$save2['image']}", $info, $config['gallery_thumb_w'], $config['gallery_thumb_h'])) {
                 $ret['ret_gallery_pic'] = 'DO_NOT_UPLOAD';
                 $input = 'gallery_pic';
                 $error = 'DO_NOT_UPLOAD';
             }
             // ลบไฟล์เดิม
             if (!empty($index['image']) && $save2['image'] != $index['image']) {
示例#2
0
 $save['last_update'] = $mmktime;
 $save['count'] = (int) $index['count'] + 1;
 // path เก็บไฟล์
 $dir = DATA_PATH . "gallery/{$save['album_id']}/";
 foreach ($_FILES as $file) {
     // ตรวจสอบไฟล์อัปโหลด
     $info = gcms::isValidImage($config['gallery_image_type'], $file);
     if (!$info) {
         $ret['error'] = 'INVALID_FILE_TYPE';
     } else {
         while (is_file($dir . "{$save['count']}.{$info['ext']}")) {
             $save['count']++;
         }
         $save['image'] = "{$save['count']}.{$info['ext']}";
         // อัปโหลดรูปภาพจริง
         $res = gcms::resizeImage($file['tmp_name'], $dir, $save['image'], $info, $config['gallery_image_w']);
         if (!$res) {
             $ret['error'] = 'DO_NOT_UPLOAD';
         } else {
             $save['image'] = $res['name'];
         }
         // อัปโหลด thumbnail
         if (!gcms::cropImage($file['tmp_name'], $dir . "thumb_{$save['image']}", $info, $config['gallery_thumb_w'], $config['gallery_thumb_h'])) {
             $ret['error'] = 'DO_NOT_UPLOAD';
         } else {
             // บันทึกลง db
             $db->add(DB_GALLERY, $save);
         }
     }
 }
 // อัปเดทจำนวนรูปภาพในอัลบัม