function _uploadYPY($upfile) { global $db, $bidcmskey; $up = new upload($upfile); $upyun = new UpYun("imgbuket", "tolecen", "11311451167llx"); $c = "abcdefghigklmnopqrstuvwxyz0123456789"; $d = substr($c, rand(0, 20), 2) . '/' . substr($c, rand(0, 10), 2); $dir = 'data/upload'; $uploaddir = ROOT_PATH . '/' . $dir; $up->max_upload = 10486000; $up->insertid = array(); $up->updir = $uploaddir ? $uploaddir : 'data/upload'; $img = array(); $imgtype = array('jpg' => '0', 'gif' => '1', 'png' => '2', 'bmp' => '3'); if ($up->checkIsFile() && $up->checkStatus() && $up->checkType() && $up->checkSize()) { if ($file = $up->execute()) { $r = getimagesize($file); $filePath = str_replace(ROOT_PATH, "", $uploaddir) . "/"; $pos = strrpos($file, '/') + 1; $fileName = substr($file, $pos); $filekey = $bidcmskey . $imgtype[$up->suffpix] . $up->fname[0] . str_replace('/', '', $d); $fh = fopen($uploaddir . "/" . $fileName, 'r'); $upyun->writeFile("/" . $fileName, $fh); fclose($fh); if (is_file($uploaddir . "/" . $fileName)) { @unlink($uploaddir . "/" . $fileName); } $db->query("insert into " . tname("file") . "(`file_key`, `file_path`, `file_original`, `file_type`, `width`, `height`)values('" . $filekey . "','" . $filePath . "','" . $fileName . "','" . $r['mime'] . "','" . $r['0'] . "','" . $r[1] . "')"); $up->insertid = array('file_id' => $db->insert_id(), 'key_path' => $filePath, 'key' => $fileName, 'type' => $r['mime'], 'width' => $r[0], 'height' => $r[1]); } } return $up; }
for ($i = 0; $i < count($_FILES['attach']['name']); $i++) { if (!empty($_FILES['attach']['name'][$i])) { $is_true++; } } if ($is_true == 0) { action_return(0, $a_langpackage->a_no_pht, "-1"); } $base_root = "uploadfiles/album/"; //图片存放目录 $up = new upload(); $up->set_dir($base_root, '{y}/{m}/{d}'); //目录设置 $up->set_thumb(180, 180); //缩略图设置 $fs = $up->execute(); $i = 0; foreach ($fs as $index => $realtxt) { if ($realtxt['flag'] == 1) { $fileSrcStr = str_replace(dirname(__FILE__), "", $realtxt['dir']) . $realtxt['name']; $thumb_src = str_replace(dirname(__FILE__), "", $realtxt['dir']) . $realtxt['thumb']; $sql = "insert into {$t_photo}(`user_id`,`add_time`,`photo_src`,`photo_thumb_src`,`album_id`,`user_name`,`privacy`)\r\n\t\t\t\t\t values({$user_id},now(),'{$fileSrcStr}','{$thumb_src}',{$album_id},'{$user_name}','');"; if ($dbo->exeUpdate($sql)) { $photo_id = mysql_insert_id(); $fs[$index]['photo_id'] = $photo_id; $sql = "update {$t_album} set photo_num=photo_num+1,update_time=NOW() where album_id={$album_id}"; if ($dbo->exeUpdate($sql)) { increase_integral($dbo, $int_photo, $user_id); } $photos_array[$i]['id'] = $photo_id; $photos_array[$i]['file'] = $thumb_src;
function _attach($upfile, $uploaddir = '', $thumbinfo = array()) { $thumb = array(); if ($_FILES) { include ROOT_PATH . '/inc/upload.class.php'; $count = count($_FILES[$upfile]['name']); foreach ($_FILES[$upfile] as $k => $v) { for ($i = 0; $i < $count; $i++) { $f['tmpupload' . $i][$k] = $v[$i]; } } $_FILES = $f; foreach ($f as $k => $v) { $up = new upload($k); $up->updir = $uploaddir ? $uploaddir : $GLOBALS['uploaddir']; if ($up->checkFile()) { if ($file = $up->execute()) { if ($thumbinfo) { $up->setThumb($file, $file, $thumbinfo['width'], $thumbinfo['height']); } $thumb[] = $file; } } } } return $thumb; }