Пример #1
1
 /**
  * 上传文件的主处理方法
  * @param $base64
  * @return mixed
  */
 private function upFile($base64)
 {
     //处理base64上传
     if ("base64" == $base64) {
         $content = $_POST[$this->fileField];
         $this->base64ToImage($content);
         return;
     }
     //处理普通上传
     $file = $this->file = $_FILES[$this->fileField];
     if (!$file) {
         $this->stateInfo = $this->getStateInfo('POST');
         return;
     }
     if ($this->file['error']) {
         $this->stateInfo = $this->getStateInfo($file['error']);
         return;
     }
     if (!is_uploaded_file($file['tmp_name'])) {
         $this->stateInfo = $this->getStateInfo("UNKNOWN");
         return;
     }
     $this->oriName = $file['name'];
     $this->fileSize = $file['size'];
     $this->fileType = $this->getFileExt();
     if (!$this->checkSize()) {
         $this->stateInfo = $this->getStateInfo("SIZE");
         return;
     }
     if (!$this->checkType()) {
         $this->stateInfo = $this->getStateInfo("TYPE");
         return;
     }
     /*$this->fullName = $this->getFolder() . '/' . $this->getName();
       if ( $this->stateInfo == $this->stateMap[ 0 ] ) {
           if ( !move_uploaded_file( $file[ "tmp_name" ] , $this->fullName ) ) {
               $this->stateInfo = $this->getStateInfo( "MOVE" );
           }
       }*/
     $this->fullName = $this->getFolder() . '/' . $this->getName();
     if ($this->stateInfo == $this->stateMap[0]) {
         if (!defined('SAE_TMP_PATH')) {
             if (!move_uploaded_file($file["tmp_name"], $this->fullName)) {
                 $this->stateInfo = $this->getStateInfo("MOVE");
             }
         } else {
             $st = new SaeStorage();
             $url = $st->upload('upload', $this->fullName, $file["tmp_name"]);
             if (!$url) {
                 $this->stateInfo = $this->getStateInfo("MOVE");
             } else {
                 $this->fullName = $url;
             }
         }
     }
 }
Пример #2
1
<?php

session_start();
include_once 'saestorage.class.php';
?>

<html>

	<body>
		<form action="index.php" method="post" enctype="multipart/form-data">
			<input type = "file" name="myfile" size="100" /><br>
			<input type = "submit" value= "upload" / >
		</form>
	</body>
</html>

<?php 
$domain = "itemsimage";
$file_name = $_FILES["myfile"]["name"];
$temp_arr = explode(".", $file_name);
$file_ext = array_pop($temp_arr);
$file_ext = trim($file_ext);
$file_ext = strtolower($file_ext);
$new_file_name = date("YmdHis") . '_' . rand(10000, 99999) . '.' . $file_ext;
$s = new SaeStorage();
//$s->upload( 'imagefile',$_FILES["myfile"]["name"],$_FILES["myfile"]["name"]);
echo $aimage = $s->upload('itemsimage', $new_file_name, $_FILES["myfile"]["tmp_name"]);
echo md5("123456");
Пример #3
0
 /**
  * 用flash添加照片
  */
 function add_photo()
 {
     if ($_FILES) {
         global $php;
         $php->upload->thumb_width = 136;
         $php->upload->thumb_height = 136;
         $php->upload->max_width = 500;
         $php->upload->max_height = 500;
         $php->upload->thumb_qulitity = 100;
         if (class_exists('SaeStorage', false)) {
             $s = new SaeStorage();
             $file_id = uniqid('pic_', false) . mt_rand(1, 100);
             $tmp_file = SAE_TMP_PATH . '/thum_' . $file_id . '.jpg';
             Image::thumbnail($_FILES['Filedata']['tmp_name'], $tmp_file, $php->upload->thumb_width, $php->upload->thumb_height, $php->upload->thumb_qulitity, false);
             $pic = '/uploads/' . $file_id . ".jpg";
             $ret = $s->upload('static', $pic, $_FILES['Filedata']['tmp_name']);
             if ($ret) {
                 $data['picture'] = $s->getUrl('static', $pic);
             } else {
                 echo $s->errmsg() . ' : ' . $s->errno();
                 return;
             }
             $thum_pic = '/uploads/thum_' . $file_id . '.jpg';
             $ret = $s->upload('static', $thum_pic, $tmp_file);
             if ($ret) {
                 $data['imagep'] = $s->getUrl('static', $thum_pic);
             } else {
                 echo $s->errmsg() . ' : ' . $s->errno();
                 return;
             }
         } else {
             $php->upload->sub_dir = 'user_images';
             $up_pic = Swoole::$php->upload->save('Filedata');
             if (empty($up_pic)) {
                 return '上传失败,请重新上传! Error:' . $php->upload->error_msg;
             }
             $data['picture'] = $up_pic['name'];
             $data['imagep'] = $up_pic['thumb'];
         }
         $data['uid'] = $_POST['uid'];
         $up_pic['photo_id'] = $this->swoole->model->UserPhoto->put($data);
         /* if(isset($_POST['post']))
            {
            	Api::feed('photo', $data['uid'], 0, $up_pic['photo_id']);
            } */
         return json_encode($up_pic);
     } else {
         $this->swoole->tpl->display('myphoto_add_photo.html');
     }
 }
Пример #4
0
 static function upradio($radio)
 {
     $s = new SaeStorage();
     $mname = $_FILES[$radio]['name'];
     $msize = $_FILES[$radio]['size'];
     if ($mname != "") {
         if ($msize > 10240000) {
             echo '图片大小不能超过10M';
             exit;
         }
         $type = strstr($mname, '.');
         if ($type != ".mp3") {
             echo '对不起!只支持mp3格式,如果是这几种格式请去掉处文件标识符以外的点"."';
             exit;
         }
         if (!$_FILES[$radio]['name']) {
             die('没有选择文件!');
         }
         //上传文件校验,可以添加文件类型等检验、此处简略处理
         $file_name = "m_" . time() . rand(100, 999);
         //定义保存的文件名称
         $m_path = $file_name . $type;
         //要保存的文件路径+文件名,此处保存在根目录下
         $link = $s->upload('upcon', $m_path, $_FILES[$radio]['tmp_name']);
         if ($link) {
             $out_radio = array('m_name' => $file_name, 'm_url' => $link);
             echo json_encode($out_radio);
         } else {
             $emsg = $s->errmsg();
             $this->writelog_debug($emsg);
             die('上传零时文件失败!');
         }
     }
 }
Пример #5
0
 function submit()
 {
     //var_dump($_FILES);exit;
     if (!$this->has_privilege()) {
         $this->json->output(array('success' => false, 'm' => '您没有使用该功能的权限'));
     }
     $proj_id = $this->input->post('proj_id');
     if (!$this->utility->chk_id($proj_id)) {
         $this->json->output(array('success' => false, 'm' => '输入的记录编号错误'));
     }
     $max_size = 10;
     // filesize MB
     if ($_FILES['file']['size'] > $max_size * 1024 * 1024) {
         $this->json->output(array('success' => false, 'm' => '上传文件大小不能超过' . $max_size . 'MB'));
     }
     if (!empty($_FILES)) {
         $s = new SaeStorage(SAE_ACCESSKEY, SAE_SECRETKEY);
         $url = $s->upload('upload', $_FILES['file']['name'], $_FILES['file']['tmp_name']);
         if (!$url) {
             $this->json->output(array('success' => false, 'm' => $s->errmsg()));
         }
         // insert into upload table
         $id = $this->Proj_model->create_upload($proj_id, $_FILES['file']['name'], $_FILES['file']['size']);
         // extjs json decode bug, using echo instead of output
         // $this->json->output(array('success' => true, 'url' => $url));
         echo '{"success":true, "file":"' . $_FILES['file']['name'] . '"}';
         exit;
     }
 }
Пример #6
0
function saeup($date, $filename)
{
    $storage = new SaeStorage();
    $domain = 'img';
    $destFileName = $filename . 'jpg';
    $srcFileName = $_FILES['tmp_name'];
    $result = $storage->upload($domain, $destFileName, $date["tmp_name"]);
    return $result;
}
Пример #7
0
/**
 * @param $tmp
 * @param $upload
 */
function Storage($tmp, &$upload)
{
    global $zbp, $domainname;
    $filename = date("Ymd", time()) . mt_rand(1000, 9999) . '_' . mt_rand(0, 1000) . '.' . GetFileExt($upload->SourceName);
    $object = date("Y/m/", time()) . $filename;
    //构造云文件名
    $upload->Name = $filename;
    $s = new SaeStorage();
    $url = $s->upload($domainname, $object, $tmp);
    $upload->Metas->Storage_URL = $object;
    $GLOBALS['Filter_Plugin_Upload_SaveFile']['Storage'] = PLUGIN_EXITSIGNAL_RETURN;
}
Пример #8
0
function upload_mp3($filePath, $fileName)
{
    $stor = new SaeStorage();
    $stor->upload(SAE_DOMAIN, $fileName, $filePath);
    $errmsg = $stor->errmsg();
    //var_export($errmsg);
    if ($errmsg == 0) {
        $result['success'] = 1;
        $result['url'] = $stor->getUrl(SAE_DOMAIN, $fileName);
    } else {
        $result['success'] = -1;
    }
    return $result;
}
Пример #9
0
function SaeStorageUpload($FilePath, $srcFileName)
{
    $storage = new SaeStorage();
    $domain = Sae_Storage_Domain_Name;
    //domain名称
    //$srcFileName = $_FILE['tmp_name'];//参数类似这样
    $size = -1;
    //长度限制
    //$attr = array('encoding'=>'gzip');//文件属性(gzip压缩)
    //$compress = true;//文件是否gzip压缩
    $attr = array();
    $compress = false;
    $result = $storage->upload($domain, $FilePath, $srcFileName, $size, $attr, $compress);
    return $result;
}
Пример #10
0
 private function upFile($base64)
 {
     if ("base64" == $base64) {
         $content = $_POST[$this->fileField];
         $this->base64ToImage($content);
         return null;
     }
     $file = $this->file = $_FILES[$this->fileField];
     if (!$file) {
         $this->stateInfo = $this->getStateInfo("POST");
         return null;
     }
     if ($this->file["error"]) {
         $this->stateInfo = $this->getStateInfo($file["error"]);
         return null;
     }
     if (!is_uploaded_file($file["tmp_name"])) {
         $this->stateInfo = $this->getStateInfo("UNKNOWN");
         return null;
     }
     $this->oriName = $file["name"];
     $this->fileSize = $file["size"];
     $this->fileType = $this->getFileExt();
     if (!$this->checkSize()) {
         $this->stateInfo = $this->getStateInfo("SIZE");
         return null;
     }
     if (!$this->checkType()) {
         $this->stateInfo = $this->getStateInfo("TYPE");
         return null;
     }
     $this->fullName = $this->getFolder() . "/" . $this->getName();
     if ($this->stateInfo == $this->stateMap[0]) {
         if (!defined("SAE_TMP_PATH")) {
             if (!move_uploaded_file($file["tmp_name"], $this->fullName)) {
                 $this->stateInfo = $this->getStateInfo("MOVE");
             }
         } else {
             $st = new SaeStorage();
             $url = $st->upload("data", $this->fullName, $file["tmp_name"]);
             if (!$url) {
                 $this->stateInfo = $this->getStateInfo("MOVE");
             } else {
                 $this->fullName = $url;
             }
         }
     }
 }
Пример #11
0
 /**
  * 保存指定文件
  * @param  array   $file    保存的文件信息
  * @param  boolean $replace 同名文件是否覆盖
  * @return boolean          保存状态,true-成功,false-失败
  */
 public function save($file, $replace = true)
 {
     $filename = ltrim($this->rootPath . '/' . $file['savepath'] . $file['savename'], '/');
     $st = new \SaeStorage();
     /* 不覆盖同名文件 */
     if (!$replace && $st->fileExists($this->domain, $filename)) {
         $this->error = '存在同名文件' . $file['savename'];
         return false;
     }
     /* 移动文件 */
     if (!$st->upload($this->domain, $filename, $file['tmp_name'])) {
         $this->error = '文件上传保存错误![' . $st->errno() . ']:' . $st->errmsg();
         return false;
     }
     return true;
 }
Пример #12
0
 /**
  * 保存上传文件
  *
  * 需要设置存放SAE的domain,可修改 Upload::$default_directory = 'newdomain';
  *
  * @param array $file
  * @param string $filename
  * @param string $directory
  * @param int $chmod
  */
 public static function save(array $file, $filename = NULL, $directory = NULL, $chmod = 0644)
 {
     if (!isset($file['tmp_name']) or !is_uploaded_file($file['tmp_name'])) {
         // Ignore corrupted uploads
         return false;
     }
     if ($filename === null) {
         // Use the default filename, with a timestamp pre-pended
         $filename = uniqid() . $file['name'];
     }
     if (Upload::$remove_spaces === true) {
         // Remove spaces from the filename
         $filename = preg_replace('/\\s+/', '_', $filename);
     }
     $obj = new SaeStorage();
     return $obj->upload(Upload::$default_directory, $filename, $file['tmp_name']);
 }
Пример #13
0
function handleFiles($typeId, $tmpNames, $names)
{
    global $IS_SAE;
    $result = array("success" => true, "details" => array());
    $ext_arr = array();
    for ($i = 0; $i < count($names); $i++) {
        $tmp = explode(".", $names[$i]);
        $tmp = $tmp[count($tmp) - 1];
        array_push($ext_arr, $tmp);
    }
    // when name the folder, here we wipe the parameter $type.
    $directory = "../resources/chart/{$typeId}/";
    if ($IS_SAE) {
        $st = new SaeStorage();
        $attr = array('encoding' => 'gzip');
        for ($i = 0; $i < count($names); $i++) {
            $tName = $tmpNames[$i];
            $oName = $names[$i];
            $file_new_name = date("YmdHis") . str_pad(rand(0, 9999), 4, rand(0, 9), STR_PAD_LEFT) . "." . $ext_arr[$i];
            $uploadRes = $st->upload($_SERVER['HTTP_APPNAME'], $file_new_name, $_FILES['photo']['tmp_name'][$i], $attr, true);
            if ($uploadRes === false) {
                array_push($result["details"], array("success" => false, "msg" => "图片'{$oName}'上传失败!error:" . $st->errno() . ' ' . $st->errmsg(), "file" => '', "original_file_name" => $oName));
            } else {
                array_push($result["details"], array("success" => true, "msg" => "图片'{$oName}'上传成功!重命名为'{$file_new_name}'。", "file" => $uploadRes, "original_file_name" => $oName));
            }
        }
    } else {
        if (!file_exists($directory)) {
            if (!mkdir($directory)) {
                throw new Exception("文件夹创建失败!" . $directory);
            }
        }
        for ($i = 0; $i < count($names); $i++) {
            $tName = $tmpNames[$i];
            $oName = $names[$i];
            $file_new_name = date("YmdHis") . str_pad(rand(0, 9999), 4, rand(0, 9), STR_PAD_LEFT) . "." . $ext_arr[$i];
            if (move_uploaded_file($tName, $directory . $file_new_name)) {
                array_push($result["details"], array("success" => true, "msg" => "图片'{$oName}'上传成功!重命名为'{$file_new_name}'。", "file" => $directory . $file_new_name, "original_file_name" => $oName));
            } else {
                array_push($result["details"], array("success" => false, "msg" => "图片'{$oName}'上传失败!", "file" => '', "original_file_name" => $oName));
            }
        }
    }
    return $result;
}
Пример #14
0
 public function Save($file, $fileType)
 {
     $res = $this->Validate($file, $fileType);
     if ($res['result']) {
         $file_name = md5($file['name'] . uniqid()) . $res['reason'];
         //sae upload
         $s = new SaeStorage();
         $save_path = SAE_MODULES . '/' . $file_name;
         $save = $s->upload(SAE_STORAGE_DOMAIN, $save_path, $file["tmp_name"]);
         if ($save !== false) {
             $res['reason'] = $file_name;
         } else {
             $res['result'] = false;
             $res['reason'] = $this->messages['3'];
         }
     }
     return $res;
 }
Пример #15
0
 function submit()
 {
     //var_dump($_FILES);exit;
     if (!$this->has_privilege()) {
         $this->json->output(array('success' => false, 'm' => '您没有使用该功能的权限'));
     }
     $remark = $this->input->post('remark');
     $dir_path = $this->input->post('dir_path');
     //if(!$this->utility->chk_id($proj_id)) {
     //	$this->json->output(array('success' => false, 'm' => '输入的记录编号错误'));
     //}
     $max_size = 20;
     // filesize MB
     if ($_FILES['file']['size'] > $max_size * 1024 * 1024) {
         $this->json->output(array('success' => false, 'm' => '上传文件大小不能超过' . $max_size . 'MB'));
     }
     $store_filename = $this->encrypt->sha1($_FILES['file']['name'] . date('Y-m-d H:i:s'));
     if (!empty($_FILES)) {
         $s = new SaeStorage(SAE_ACCESSKEY, SAE_SECRETKEY);
         $url = $s->upload('library', $store_filename, $_FILES['file']['tmp_name']);
         if (!$url) {
             $this->json->output(array('success' => false, 'm' => $s->errmsg()));
         }
         // insert into upload table
         $file_list = $this->Library_model->get_upload_by_name($_FILES['file']['name'], $dir_path, 'normal');
         $version = 1;
         if (count($file_list) > 1) {
             echo '{"success":false}';
             exit;
         } else {
             if (count($file_list) == 1) {
                 $version = $file_list[0]->version;
             }
         }
         $id = $this->Library_model->create_upload($remark, $_FILES['file']['name'], $_FILES['file']['size'], $dir_path, '', $store_filename, $version);
         // extjs json decode bug, using echo instead of output
         // $this->json->output(array('success' => true, 'url' => $url));
         echo '{"success":true, "file":"' . $_FILES['file']['name'] . '"}';
         exit;
     }
 }
Пример #16
0
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Article'])) {
         $model->attributes = $_POST['Article'];
         $model->imgurl = CUploadedFile::getInstance($model, 'imgurl');
         if ($model->imgurl) {
             $newimg = 'article_' . time() . '_' . rand(1, 9999) . '.' . $model->imgurl->extensionName;
             $uploadimage = new SaeStorage();
             $uploadimage->upload('upload', $newimg, $model->imgurl->tempName);
             $model->imgurl = $newimg;
         } else {
             $model->imgurl = $_POST['imgpath2'];
         }
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('update', array('model' => $model));
 }
Пример #17
0
 private static function upFile()
 {
     if (!self::$file) {
         //不存在上传的文件
         self::$status = self::$ERROR[1];
         return;
     }
     self::$error = self::$file['error'];
     if (self::$error) {
         //上传有错误id返回
         self::error(self::$error);
         return;
     }
     //上传文件是否小于配置文件大小
     self::$size = self::$file['size'];
     if (self::$size > self::$config['maxSize']) {
         self::$status = self::$ERROR[2];
         return;
     }
     //是否为上传文件
     self::$tmpName = self::$file['tmp_name'];
     if (!is_uploaded_file(self::$tmpName)) {
         self::$status = self::$ERROR[3];
         return;
     }
     self::$type = self::$file['type'];
     $type = explode('/', self::$type);
     $suffix = $type[count($type) - 1];
     if (!in_array($suffix, self::$config['allowType'])) {
         self::$status = self::$ERROR[4];
         return;
     }
     self::$oldName = self::$file['name'];
     //得到随机文件名
     $fileName = explode('.', self::$oldName);
     $fileName = time() . '.' . $suffix;
     if (substr(self::$path, 0, 1) != '/') {
         self::$path = '/' . self::$path;
     }
     $data = date('Ymd');
     //sae下
     if (class_exists('SaeMysql')) {
         $fullName = self::$path . '/' . $data . '/' . $fileName;
         $s = new \SaeStorage();
         $dir = $s->upload('lxpfigo', $fullName, self::$tmpName);
         if ($dir) {
             self::$path = $dir;
             self::$status = self::$ERROR[0];
         } else {
             self::$status = self::$ERROR[7];
             return;
         }
     } else {
         $fullName = $_SERVER['DOCUMENT_ROOT'] . self::$path . '/' . $data . '/' . $fileName;
         if (!file_exists(dirname($fullName)) && !mkdir(dirname($fullName), 0777, true)) {
             self::$status = self::$ERROR[5];
             return;
         } else {
             if (!is_writeable(dirname($fullName))) {
                 self::$status = self::$ERROR[6];
                 return;
             }
         }
         //移动文件
         if (!(move_uploaded_file(self::$tmpName, $fullName) && file_exists($fullName))) {
             //移动失败
             self::$status = self::$ERROR[7];
             return;
         } else {
             //移动成功
             self::$path = $fullName;
             self::$status = self::$ERROR[0];
             return;
         }
     }
 }
Пример #18
0
 static function show_upload_topic($pic)
 {
     define('TEMP', 'topic');
     //要上传的缓存storage名称定义
     $s = new SaeStorage();
     $picname = $_FILES[$pic]['name'];
     $picsize = $_FILES[$pic]['size'];
     if ($picname != "") {
         if ($picsize > 5120000) {
             echo '图片大小不能超过2M';
             exit;
         }
         $type = strstr($picname, '.');
         if ($type != ".gif" && $type != ".jpg" && $type != ".png" && $type != ".jpeg") {
             echo '图片格式不对!只支持jpg,png,gif';
             exit;
         }
         if (!$_FILES[$pic]['name']) {
             die('没有选择文件!');
         }
         //上传文件校验,可以添加文件类型等检验、此处简略处理
         $file_name = "topic_" . time() . rand(100, 999);
         //定义保存的文件名称
         $ext = end(explode('.', $_FILES[$pic]['name']));
         //获得扩展名
         $pic_path = $file_name . '.' . $ext;
         //要保存的文件路径+文件名,此处保存在upload/目录下
         if ($s->upload(TEMP, $pic_path, $_FILES[$pic]['tmp_name'])) {
             //裁成三种大小
             $poc = array(array(200, 200, '_big.jpg'), array(64, 64, '_midde.jpg'), array(22, 22, '_small.jpg'));
             //将图片剪裁之后存入storage
             foreach ($poc as $p) {
                 $pict = $file_name . $p[2];
                 $data = self::clip_topic($p[0], $p[1], $pic_path, "center", TEMP);
                 $url = $s->write(TEMP, $pict, $data);
                 if ($url == FALSE) {
                     die('图片剪裁写入失败!');
                 }
                 $pics[] = $url;
                 unset($data);
                 unset($pict);
             }
             //如果不是jpg格式则重新写入jpg格式
             if ($ext != 'jpg') {
                 $data = $s->read(TEMP, $pic_path);
                 if (!$s->write(TEMP, $file_name . '.jpg', $data)) {
                     die('图片写入失败!');
                 }
             }
             //获取三个图片地址
             $pics_b = $pics[0];
             $pics_m = $pics[1];
             $pics_s = $pics[2];
         } else {
             $emsg = '上传零时文件失败' . $s->errmsg();
             sae_debug($emsg);
             die($emsg);
         }
         //将三种地址放入数组输出
         $out_pic = array('pic_name' => array($file_name, $ext), 'pic_url' => array($pics_b, $pics_m, $pics_s));
         return $out_pic;
     }
 }
Пример #19
0
 /**
  * 修改文件处理函数
  *
  * @access public
  * @param array $content 老文件
  * @param array $file 新上传的文件
  * @return mixed
  */
 public static function modifyHandle($content, $file)
 {
     if (empty($file['name'])) {
         return false;
     }
     $fileName = preg_split("(\\/|\\|:)", $file['name']);
     $file['name'] = array_pop($fileName);
     //获取扩展名
     $ext = '';
     $part = explode('.', $file['name']);
     if (($length = count($part)) > 1) {
         $ext = strtolower($part[$length - 1]);
     }
     if ($content['attachment']->type != $ext) {
         return false;
     }
     //获取文件名
     $fileName = $content['attachment']->path;
     $path = $path . '/' . $fileName;
     //add for mkdir
     $stor = new SaeStorage();
     $options = Typecho_Widget::widget('Widget_Options');
     $SaeStorageDomain = $options->plugin('SaeUpload')->saestoragedomain;
     if (isset($file['tmp_name'])) {
         //移动上传文件
         if (!($path = $stor->upload($SaeStorageDomain, $fileName, $file['tmp_name']))) {
             return false;
         }
     } else {
         if (isset($file['bits'])) {
             //直接写入文件
             if (!($path = $stor->write($SaeStorageDomain, $fileName, $file['bits']))) {
                 return false;
             }
         } else {
             return false;
         }
     }
     if (!isset($file['size'])) {
         $attr = $stor->getAttr($SaeStorageDomain, $fileName, array('length'));
         $file['size'] = $attr['length'];
     }
     //返回相对存储路径
     return array('name' => $content['attachment']->name, 'path' => $content['attachment']->path, 'size' => $file['size'], 'type' => $content['attachment']->type, 'mime' => $content['attachment']->mime);
 }
Пример #20
0
 $propertytmpname2 = $_FILES["propertymyfile_2"]["tmp_name"];
 $propertyimagelocation2 = "{$propertyimagename2}";
 $storage = new SaeStorage();
 $domain = "upload";
 //storage名
 $storage->upload($domain, $propertyimagename2, $propertytmpname2);
 //上传
 $url_2 = $storage->getUrl($domain, $propertyimagename2);
 //move_uploaded_file($propertytmpname,$propertyimagelocation);
 $propertyimagename3 = $_FILES["propertymyfile_3"]["name"];
 $propertytmpname3 = $_FILES["propertymyfile_3"]["tmp_name"];
 $propertyimagelocation3 = "{$propertyimagename3}";
 $storage = new SaeStorage();
 $domain = "upload";
 //storage名
 $storage->upload($domain, $propertyimagename3, $propertytmpname3);
 //上传
 $url_3 = $storage->getUrl($domain, $propertyimagename3);
 //move_uploaded_file($propertytmpname,$propertyimagelocation);
 $insert = $pdo->prepare("UPDATE propertytable SET Property_Name= :propertyname, Property_Address= :propertyaddress, Property_ZipCode=:propertyzipcode, Contact_Name=:contactname, Contact_Number=:contactnumber, Property_Type=:propertytype, Property_Description=:propertydescription, \n                               Property_ImageLocation_1=:propertyimagelocation1, Property_ImageLocation_2=:propertyimagelocation2, Property_ImageLocation_3=:propertyimagelocation3, bedroom_num=:bedroom_num, bathroom_num=:bathroom_num, price= :price, member_email=:member_email where Property_ID=:id");
 $insert->bindValue(':propertyname', $propertyname);
 $insert->bindValue(':propertyaddress', $propertyaddress);
 $insert->bindValue(':propertyzipcode', $propertyzipcode);
 $insert->bindValue(':contactname', $contactname);
 $insert->bindValue(':contactnumber', $contactnumber);
 $insert->bindValue(':propertytype', $propertytype);
 $insert->bindValue(':propertydescription', $propertydescription);
 $insert->bindValue(':propertyimagelocation1', $propertyimagelocation1);
 $insert->bindValue(':propertyimagelocation2', $propertyimagelocation2);
 $insert->bindValue(':propertyimagelocation3', $propertyimagelocation3);
 $insert->bindValue(':price', $price);
Пример #21
0
        exit;
    }
    if (!in_array($file['type'], $uptypes)) {
        $jsonArray = array('cid' => '1015', 'ret' => '2', 'reason' => '3');
        echo json_encode($jsonArray);
        exit;
    }
    $s = new SaeStorage();
    $domin = 'userupload';
    $sql = '';
    if ($type) {
        $filename = "linkedo/" . $id . "/portrait.png";
        $url = "http://linkedo-userupload.stor.sinaapp.com/" . $filename;
        $sql = "update lo_user set portraitURL ='" . $url . "' where id =" . $id;
    } else {
        $filename = "linkedo/" . $id . "/bgimage.png";
        $url = "http://linkedo-userupload.stor.sinaapp.com/" . $filename;
        $sql = "update lo_user set bgimageURL ='" . $url . "' where id =" . $id;
    }
    $s->upload($domin, $filename, $_FILES["upfile"]['tmp_name']);
    $result = $mysqli->query($sql);
    if ($result) {
        $jsonArray = array('cid' => '1015', 'ret' => '1');
    } else {
        $jsonArray = array('cid' => '1015', 'ret' => '2', 'reason' => '0');
    }
    echo json_encode($jsonArray);
} else {
    $jsonArray = array('cid' => '1015', 'ret' => '0');
}
$mysqli->close();
Пример #22
0
$conn = mysqli_connect(SAE_MYSQL_HOST_M . ':' . SAE_MYSQL_PORT, SAE_MYSQL_USER, SAE_MYSQL_PASS, SAE_MYSQL_DB);
if (!conn) {
    die("connect failed");
}
if ($_SERVER['HTTP_FUNCTION'] === "upload") {
    $Uid = $_POST['Uid'];
    $sql = "insert ignore \n                into User(Uid)\n                values ('{$Uid}')";
    $res = mysqli_query($conn, $sql);
    $files = $_FILES['imageFile'];
    $storage = new SaeStorage();
    $domain = 'pictures';
    $srcFileName = $files['tmp_name'];
    $subUid = substr($Uid, 0, 8);
    $destFileName = $subUid . '_' . date(y_m_d_H_i_s) . '.png';
    $result = $storage->upload($domain, $destFileName, $srcFileName);
    echo $result;
    $longitude = $_POST['longitude'];
    $latitude = $_POST['latitude'];
    $address = $_POST['address'];
    $sql = "insert \n                into Picture(Uid, Url, longitude, latitude, address)\n                values ('{$Uid}', '{$result}', '{$longitude}', '{$latitude}', '{$address}')";
    $res = mysqli_query($conn, $sql);
} else {
    if ($_SERVER['HTTP_FUNCTION'] === "download") {
        $sql = "select * from Picture";
        $res = mysqli_query($conn, $sql);
        $sumOfPic = mysqli_num_rows($res);
        $randomNums = getSevenRandomNums($sumOfPic);
        $urlArray = array();
        for ($i = 0; $i < 7; $i++) {
            $num = $randomNums[$i];
Пример #23
0
 $content = htmlspecialchars($_POST['content']);
 $sql = "INSERT INTO lo_share (headline, content, field_id, user_id) VALUES ('" . $headline . "','" . $content . "'," . $field_id . "," . $user_id . ");";
 $result = $mysqli->query($sql);
 if ($result) {
     $images = $_FILES['images']['error'];
     $i = 0;
     $domin = 'userupload';
     $id = $mysqli->insert_id;
     $filespath = '';
     foreach ($images as $key => $error) {
         if ($error == UPLOAD_ERR_OK) {
             $filename = "linkedo/" . $user_id . "/" . $id . "/" . time() . $i . ".png";
             $tmp_name = $_FILES['images']['tmp_name'][$key];
             $s = new SaeStorage();
             $filespath = $filespath . $filename . '|';
             $s->upload($domin, $filename, $tmp_name);
             $i++;
         } else {
             $jsonArray = array('cid' => '1005', 'ret' => '1', 'image_error' => $i);
             echo json_encode($jsonArray);
         }
     }
     $sql = "update lo_share set images = '" . $filespath . "' where id=" . $id;
     $result = $mysqli->query($sql);
     if ($result) {
         $jsonArray = array('cid' => '1005', 'ret' => '1');
         echo json_encode($jsonArray);
     } else {
         $jsonArray = array('cid' => '1005', 'ret' => '0');
         echo json_encode($jsonArray);
     }
Пример #24
0
/*
Uploadify
Copyright (c) 2012 Reactive Apps, Ronnie Garcia
Released under the MIT License <http://www.opensource.org/licenses/mit-license.php> 
*/
$domain = "uploads";
// Define a destination
$targetFolder = '/upload/uploads';
// Relative to the root
//$verifyToken = md5('unique_salt' . $_POST['timestamp']);
//$_SESSION['DATA'] = "123";
//if (!empty($_FILES) && $_POST['token'] == $verifyToken) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
$targetFile = rtrim($targetPath, '/') . '/' . $_FILES['Filedata']['name'];
// Validate the file type
$fileTypes = array('jpg', 'jpeg', 'gif', 'png');
// File extensions
$fileParts = pathinfo($_FILES['Filedata']['name']);
$tar = "/uploads" . '/' . md5(time()) . $_FILES['Filedata']['name'];
if (in_array($fileParts['extension'], $fileTypes)) {
    $s = new SaeStorage();
    $s->upload($domain, $tar, $tempFile);
    $file_url = $s->getUrl($domain, $tar);
    echo $file_url;
    //$file_url =  $s->getUrl( $domain , $new_file_name);
    //move_uploaded_file($tempFile,$targetFile);
} else {
    echo 'Invalid file type.';
}
//}
Пример #25
-1
							<div id="shieldui-grid1">
<?php 
$domain = "test";
$file_name = $_FILES["imgFile"]["name"];
$allow_ext = array('image' => array('gif', 'jpg', 'jpeg', 'png', 'bmp'), 'flash' => array('swf', 'flv'), 'media' => array('swf', 'flv', 'mp3', 'wav', 'wma', 'wmv', 'mid', 'avi', 'mpg', 'asf', 'rm', 'rmvb'), 'file' => array('doc', 'docx', 'xls', 'xlsx', 'ppt', 'htm', 'html', 'txt', 'zip', 'rar', 'gz', 'bz2'));
//容许的文件扩展名
$file_ext = strtolower(trim(array_pop(explode(".", $file_name))));
$dir_name = empty($_POST['dir']) ? 'image' : trim($_POST['dir']);
if (in_array($file_ext, $allow_ext[$dir_name]) === false) {
    alert("不支持的扩展名,目前我们仅支持以下扩展名:" . implode(',', $allow_ext[$dir_name]));
    exit;
}
$new_file_name = $dir_name . '/' . date("Ymd") . '/' . time() . '.' . $file_ext;
$s = new SaeStorage();
//$s->upload( 'imagefile',$_FILES["myfile"]["name"],$_FILES["myfile"]["name"]);
$aimage = $s->upload('test', $new_file_name, $_FILES["imgFile"]["tmp_name"]);
alert("文件上传成功,路径为" . $aimage);
function alert($msg)
{
    $info = array('error' => 1, 'message' => $msg);
    echo $info['message'];
    exit;
}
?>
							</div>
                        </div>
                    </div>
                </div>
            </div>
            <!-- /.row -->
        </div>
Пример #26
-1
         $count = strlen($str);
         $count -= 1;
         for ($i = 0; $i < 10; $i++) {
             $point = mt_rand(0, $count);
             $nums .= $str[$point];
         }
         if ($_FILES["file"]["type"] == "image/jpeg" || $_FILES["file"]["type"] == "image/pjpeg") {
             $_FILES["file"]["name"] = $nums . ".jpg";
         }
         if ($_FILES["file"]["type"] == "image/gif") {
             $_FILES["file"]["name"] = $nums . ".gif";
         }
         if ($_FILES["file"]["type"] == "image/png") {
             $_FILES["file"]["name"] = $nums . ".png";
         }
         $s->upload("dream", $_FILES["file"]["name"], $_FILES["file"]["tmp_name"], $attr = array(), $compress = false);
         $url = "http://hehuaqi-dream.stor.sinaapp.com/" . $_FILES["file"]["name"];
     }
 } else {
     $url_page = "http://1.hehuaqi.sinaapp.com/zhbitscda/manager_news.php?value=5";
     echo "<script language='javascript' type='text/javascript'>";
     echo "window.location.href='{$url_page}'";
     echo "</script>";
 }
 include_once "header.php";
 $query = "insert into scdanews values(NULL,'{$name}','{$content}','{$time}','{$url}')";
 $result = @mysql_query($query);
 if ($result) {
     $url_page = "http://1.hehuaqi.sinaapp.com/zhbitscda/manager_news.php?value=1";
     echo "<script language='javascript' type='text/javascript'>";
     echo "window.location.href='{$url_page}'";
<?php

//sae_debug("in oath2/callback!!!!");
require '../../lib.php';
$ret = array('ret' => 0, 'msg' => '成功');
$oauth = OpenHelper::oauthCompany();
//默认会从Get参数中拿到code去获得companyToken
$result = $oauth->getCompanyToken();
if (OpenConfig::SAE_MODE) {
    $s = new SaeStorage();
    $s->upload(OpenConfig::SAE_DOMAIN, 'data.dat', '../../data.dat');
}
if ($result['ret'] == 0 && !empty($result['data'])) {
    $company_token = $result['data'];
    $company_token['status'] = 0;
    saveToken($company_token);
} else {
    $ret['ret'] = 1;
    $ret['msg'] = '失败';
}
if (OpenConfig::SAE_MODE) {
    ini_set('display_errors', 0);
    sae_debug(json_encode($ret));
    ini_set('display_errors', 1);
}
OpenUtils::outputJson($ret);
Пример #28
-2
 public function invest_in_request()
 {
     $itemid = $this->input->post('itemid');
     $content = $this->input->post('content');
     $order = $this->Order_model->get_by_id($itemid);
     if ($order->creator != $this->get_user_info('realname')) {
         $this->json->output(array('success' => false, 'm' => '您不可以修改他人的预约!'));
     }
     if ($order->state != 'accepted') {
         $this->json->output(array('success' => false, 'm' => '您提交的订单不可修改!'));
     }
     $this->Order_model->invest_order($itemid);
     $max_size = 10;
     // filesize MB
     //var_dump($_FILES);
     if ($_FILES['file']['name'] != "") {
         if ($_FILES['file']['size'] > $max_size * 1024 * 1024) {
             $this->json->output(array('success' => false, 'm' => '上传文件大小不能超过' . $max_size . 'MB'));
         }
         $store_filename = $this->encrypt->sha1($_FILES['file']['name'] . date('Y-m-d H:i:s'));
         $s = new SaeStorage(SAE_ACCESSKEY, SAE_SECRETKEY);
         $url = $s->upload('order', $store_filename, $_FILES['file']['tmp_name']);
         if (!$url) {
             $this->json->output(array('success' => false, 'm' => $s->errmsg()));
         }
         // insert into upload table
         //$file_list = $this->Library_model->get_upload_by_name($_FILES['file']['name'], $dir_path, 'normal');
         //$id = $this->Order_model->create_upload($remark, $_FILES['file']['name'], $_FILES['file']['size'], $dir_path,'',$store_filename, $version);
         $this_step_id = $this->Reminder_model->system_create_item('order_invest', '打款确认流程:提交', '', '/order?itemid=' . $order->itemid, $order->proj_manager, 0, $this->get_user_info('realname'), $content, $content, 1, $itemid, $_FILES['file']['name'], $store_filename, $_FILES['file']['size']);
         $this->Reminder_model->system_create_item('order_invest', '打款确认流程:审核', '', '/order?itemid=' . $order->itemid, 'end', 1, $order->proj_manager, '', $content, 2, $itemid);
         $this->Reminder_model->finish_item($this_step_id);
         $flow_next_user = $this->User_model->get_by_name($order->proj_manager);
         $mail_content_title = '打 款 确 认 申 请';
         $mail_content_mainstr = '<p>以下预约正在申请确认打款:</p><p><table><tr><td>申请人: </td><td>' . $order->creator . '</td></tr>' . '<tr><td>项目名称:</td><td>' . $order->proj_name . '</td></tr>' . '<tr><td>客户姓名:</td><td>' . $order->csr_name . '</td></tr>' . '<tr><td>投资数额:</td><td>' . $order->amount . '万元</td></tr></table></p>' . '<p>请点击<a href="http://rainbowbridge.sinaapp.com/ts/index.php/order?itemid=' . $order->itemid . '"> 这里 </a>查看';
         $mail_content_buttomstr = '您收到这封邮件,是因为您是该预约产品的产品经理。';
         $mail_subject = 'YW34_打款确认申请: 预约号' . $order->itemid;
         $this->utility->noticemail_html($flow_next_user->email, $mail_subject, $mail_content_title, $mail_content_mainstr, $mail_content_buttomstr, '');
         // extjs json decode bug, using echo instead of output
         // $this->json->output(array('success' => true, 'url' => $url));
         echo '{"success":true, "file":"' . $_FILES['file']['name'] . '"}';
         exit;
     } else {
         $this_step_id = $this->Reminder_model->system_create_item('order_invest', '打款确认流程:提交', '', '/order?itemid=' . $order->itemid, $order->proj_manager, 0, $this->get_user_info('realname'), $content, $content, 1, $itemid);
         $this->Reminder_model->system_create_item('order_invest', '打款确认流程:审核', '', '/order?itemid=' . $order->itemid, 'end', 1, $order->proj_manager, '', $content, 2, $itemid);
         $this->Reminder_model->finish_item($this_step_id);
         $flow_next_user = $this->User_model->get_by_name($order->proj_manager);
         $mail_content_title = '打 款 确 认 申 请';
         $mail_content_mainstr = '<p>以下预约正在申请确认打款:</p><p><table><tr><td>申请人: </td><td>' . $order->creator . '</td></tr>' . '<tr><td>项目名称:</td><td>' . $order->proj_name . '</td></tr>' . '<tr><td>客户姓名:</td><td>' . $order->csr_name . '</td></tr>' . '<tr><td>投资数额:</td><td>' . $order->amount . '万元</td></tr></table></p>' . '<p>请点击<a href="http://rainbowbridge.sinaapp.com/ts/index.php/order?itemid=' . $order->itemid . '"> 这里 </a>查看';
         $mail_content_buttomstr = '您收到这封邮件,是因为您是该预约产品的产品经理。';
         $mail_subject = 'YW34_打款确认申请: 预约号' . $order->itemid;
         $this->utility->noticemail_html($flow_next_user->email, $mail_subject, $mail_content_title, $mail_content_mainstr, $mail_content_buttomstr, '');
         // extjs json decode bug, using echo instead of output
         // $this->json->output(array('success' => true, 'url' => $url));
         echo '{"success":true}';
         exit;
     }
 }
Пример #29
-2
function file_upload($src_file, $dest_file)
{
    if (!IS_SAE) {
        //兼容普通环境
        $pdir = dirname($dest_file);
        if (!is_dir($pdir)) {
            @mkdir($pdir, 0777);
        }
        return copy($src_file, $dest_file);
    }
    $s = new SaeStorage();
    $arr = explode('/', ltrim($dest_file, './'));
    $domain = array_shift($arr);
    $save_path = implode('/', $arr);
    return $s->upload($domain, $save_path, $src_file);
}
Пример #30
-2
 public function actionUpdateHeadimg()
 {
     $model = $this->loadModel(Yii::app()->user->id);
     if (isset($_POST['Member'])) {
         $model->headimg = CUploadedFile::getInstance($model, 'headimg');
         $this->performAjaxValidation($model, array('headimg'));
         if ($model->validate(array('headimg'))) {
             if (empty($model->headimg)) {
                 header('Content-Type: text/html; charset=utf-8;');
                 echo "<script language='javascript'>alert('上传文件不能为空');window.location.href='updateHeadimg';</script>";
                 exit;
             }
             list($usec, $sec) = explode(" ", microtime());
             $usec = substr($usec, 2, 2);
             $newFileName = 'headimg' . $sec . $usec . '.jpg';
             $uploadimage = new SaeStorage();
             $uploadimage->upload('headimg', $newFileName, $model->headimg->tempName);
             $newFile = "http://918s-headimg.stor.sinaapp.com/" . $newFileName;
             $f = new SaeFetchurl();
             $img_data = $f->fetch($newFile);
             $img = new SaeImage();
             $img->setData($img_data);
             if ($_POST['w'] && $_POST['h']) {
                 //用户选中截图工具,按照对应坐标进行截图
                 $x1 = $_POST['x1'] / 200;
                 $w = ($_POST['x1'] + $_POST['w']) / 200;
                 $y1 = $_POST['y1'] / 300;
                 $h = ($_POST['y1'] + $_POST['h']) / 300;
                 $img->crop($x1, $w, $y1, $h);
                 $img->resize(100, 100);
             } else {
                 //用户直接提交,直接对图片进行缩放
                 $img->resize(100, 100);
             }
             $data = $img->exec();
             $uploadimage->write('headimg', $newFileName, $data);
             $model->headimg = $newFileName;
             if ($model->saveAttributes(array('headimg'))) {
                 $this->redirect(array('/member/index'));
             }
         }
     }
     $this->render('updateHeadimg', array('model' => $model));
 }