当前位置: 首页>>代码示例>>PHP>>正文


PHP FileUtil::getUpload方法代码示例

本文整理汇总了PHP中FileUtil::getUpload方法的典型用法代码示例。如果您正苦于以下问题:PHP FileUtil::getUpload方法的具体用法?PHP FileUtil::getUpload怎么用?PHP FileUtil::getUpload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FileUtil的用法示例。


在下文中一共展示了FileUtil::getUpload方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct($fileArea = "Filedata", $module = "temp")
 {
     $file = $_FILES[$fileArea];
     if ($file["error"]) {
         throw new FileException(Ibos::lang("File is too big", "error"));
     } else {
         $upload = FileUtil::getUpload($file, $module);
         $this->upload = $upload;
     }
 }
开发者ID:AxelPanda,项目名称:ibos,代码行数:10,代码来源:ICAttach.php

示例2: actionUploadAvatar

 public function actionUploadAvatar()
 {
     $upload = FileUtil::getUpload($_FILES["Filedata"]);
     if (!$upload->save()) {
         $this->ajaxReturn(array("msg" => Ibos::lang("Save failed", "message"), "IsSuccess" => false));
     } else {
         $info = $upload->getAttach();
         $file = FileUtil::getAttachUrl() . "/" . $info["type"] . "/" . $info["attachment"];
         $fileUrl = FileUtil::fileName($file);
         $tempSize = FileUtil::imageSize($fileUrl);
         if ($tempSize[0] < 180 || $tempSize[1] < 180) {
             $this->ajaxReturn(array("msg" => Ibos::lang("Avatar size error"), "IsSuccess" => false), "json");
         }
         $this->ajaxReturn(array("data" => $fileUrl, "file" => $file, "IsSuccess" => true));
     }
 }
开发者ID:AxelPanda,项目名称:ibos,代码行数:16,代码来源:InfoController.php

示例3: imgUpload

 protected function imgUpload($fileArea, $inajax = false)
 {
     $_FILES[$fileArea]["name"] = StringUtil::iaddSlashes(urldecode($_FILES[$fileArea]["name"]));
     $file = $_FILES[$fileArea];
     $upload = FileUtil::getUpload($file, "dashboard");
     if ($upload->save()) {
         $info = $upload->getAttach();
         $file = FileUtil::getAttachUrl() . "/" . $info["type"] . "/" . $info["attachment"];
         if (!$inajax) {
             return $file;
         } else {
             $this->ajaxReturn(array("url" => $file));
         }
     } else {
         return false;
     }
 }
开发者ID:AxelPanda,项目名称:ibos,代码行数:17,代码来源:DashboardBaseController.php

示例4: actionUpload

 public function actionUpload()
 {
     if ($_FILES["avatar"]) {
         $upload = FileUtil::getUpload($_FILES["avatar"]);
         if (!$upload->save()) {
             echo "出错了";
         } else {
             $info = $upload->getAttach();
             $file = FileUtil::getAttachUrl() . "/" . $info["type"] . "/" . $info["attachment"];
             $fileUrl = FileUtil::fileName($file);
             $uid = Yii::app()->user->uid;
             $tempAvatar = $file;
             $avatarPath = "data/avatar/";
             $avatarBig = UserUtil::getAvatar($uid, "big");
             $avatarMiddle = UserUtil::getAvatar($uid, "middle");
             $avatarSmall = UserUtil::getAvatar($uid, "small");
             if (LOCAL) {
                 FileUtil::makeDirs($avatarPath . dirname($avatarBig));
             }
             FileUtil::createFile("data/avatar/" . $avatarBig, "");
             FileUtil::createFile("data/avatar/" . $avatarMiddle, "");
             FileUtil::createFile("data/avatar/" . $avatarSmall, "");
             Yii::import("ext.ThinkImage.ThinkImage", true);
             $imgObj = new ThinkImage(THINKIMAGE_GD);
             $imgTemp = $imgObj->open($tempAvatar);
             $params = array("w" => $imgTemp->width(), "h" => $imgTemp->height(), "x" => "0", "y" => "0");
             if ($params["h"] < $params["w"]) {
                 $params["x"] = ($params["w"] - $params["h"]) / 2;
                 $params["w"] = $params["h"];
             } else {
                 $params["y"] = ($params["h"] - $params["w"]) / 2;
                 $params["h"] = $params["w"];
             }
             $imgObj->open($tempAvatar)->crop($params["w"], $params["h"], $params["x"], $params["y"])->save($tempAvatar);
             $imgObj->open($tempAvatar)->thumb(180, 180, 1)->save($avatarPath . $avatarBig);
             $imgObj->open($tempAvatar)->thumb(60, 60, 1)->save($avatarPath . $avatarMiddle);
             $imgObj->open($tempAvatar)->thumb(30, 30, 1)->save($avatarPath . $avatarSmall);
         }
     }
 }
开发者ID:AxelPanda,项目名称:ibos,代码行数:40,代码来源:settingController.php

示例5: actionPostimg

 public function actionPostimg()
 {
     $upload = FileUtil::getUpload($_FILES["pmimage"], "mobile");
     if (!$upload->save()) {
         echo "出错了";
     } else {
         $info = $upload->getAttach();
         $file = FileUtil::getAttachUrl() . "/" . $info["type"] . "/" . $info["attachment"];
         $fileUrl = FileUtil::fileName($file);
         $filePath = FileUtil::getAttachUrl() . "/" . $info["type"] . "/" . $info["attachdir"];
         $filename = "tumb_" . $info["attachname"];
         if (LOCAL) {
             FileUtil::makeDirs($filePath . dirname($filename));
         }
         FileUtil::createFile($filePath . $filename, "");
         Yii::import("ext.ThinkImage.ThinkImage", true);
         $imgObj = new ThinkImage(THINKIMAGE_GD);
         $imgObj->open($fileUrl)->thumb(180, 180, 1)->save($filePath . $filename);
         $content = "<a href='" . $fileUrl . "'><img src='" . $filePath . $filename . "' /></a>";
         $id = intval(isset($_POST["pmid"]) ? $_POST["pmid"] : 0);
         $touid = intval(isset($_POST["pmtouid"]) ? $_POST["touid"] : 0);
         if (!$id && $touid) {
             $data = array("content" => $content, "touid" => $touid, "type" => 1);
             $res = MessageContent::model()->postMessage($data, Yii::app()->user->uid);
             $message = array("listid" => $res, "IsSuccess" => true);
         } else {
             $res = MessageContent::model()->replyMessage($id, $content, Yii::app()->user->uid);
             if ($res) {
                 $message = array("IsSuccess" => true, "data" => Ibos::lang("Private message send success"));
             } else {
                 $message = array("IsSuccess" => false, "data" => Ibos::lang("Private message send fail"));
             }
         }
         $this->ajaxReturn($message, "JSONP");
     }
 }
开发者ID:AxelPanda,项目名称:ibos,代码行数:36,代码来源:PmController.php

示例6: handleImgComponent

 protected function handleImgComponent(&$formData)
 {
     foreach ($GLOBALS["_FILES"] as $key => $value) {
         if (strtolower(substr($key, 0, 5)) == "data_") {
             $formData["{$key}"] = "";
             $old = $_POST["imgid_" . substr($key, 5)];
             if ($value["name"] != "") {
                 if (!empty($old)) {
                     AttachUtil::delAttach($old);
                 }
                 $upload = FileUtil::getUpload($_FILES[$key], "workflow");
                 $upload->save();
                 $attach = $upload->getAttach();
                 $attachment = "workflow/" . $attach["attachment"];
                 $imgData = array("dateline" => TIMESTAMP, "filename" => $attach["name"], "filesize" => $attach["size"], "isimage" => $attach["isimage"], "attachment" => $attachment, "uid" => $this->uid);
                 $aid = Attachment::model()->add(array("uid" => $this->uid, "rid" => $this->runid, "tableid" => AttachUtil::getTableId($this->runid)), true);
                 $imgData["aid"] = $aid;
                 $newAttach = AttachmentN::model()->add(sprintf("rid:%d", $this->runid), $imgData, true);
                 $formData["{$key}"] = $newAttach;
             } else {
                 $formData["{$key}"] = $old;
             }
         }
     }
 }
开发者ID:AxelPanda,项目名称:ibos,代码行数:25,代码来源:WorkController.php

示例7: actionImport

 public function actionImport()
 {
     if ($this->flowid) {
         if (EnvUtil::submitCheck("typeSubmit")) {
             $userOn = !isset($_POST["useron"]) ? false : true;
             $fileName = $_FILES["import"]["name"];
             if (!stristr($fileName, ".xml")) {
                 $this->ajaxReturn("<script type='text/javascript'>parent.Ui.alert('" . Ibos::lang("Import xml files only") . "');</script>", "eval");
             } else {
                 $upload = FileUtil::getUpload($_FILES["import"]);
                 $upload->save();
                 $files = $upload->getAttach();
                 $file = $files["target"];
                 WfTypeUtil::import($this->flowid, $file, $userOn);
                 $this->ajaxReturn("<script type='text/javascript'>parent.Ui.tip('" . Ibos::lang("Import success") . "', 'success');parent.Ui.getDialog('import_frame').close();</script>", "eval");
             }
         }
         $lang = Ibos::getLangSources();
         $this->renderPartial("import", array("lang" => $lang, "flowId" => $this->flowid));
     } else {
         $this->ajaxReturn("<script type='text/javascript'>parent.Ui.alert('" . Ibos::lang("Parameters error", "error") . "');parent.Ui.getDialog('import_frame').close();</script>", "eval");
     }
 }
开发者ID:AxelPanda,项目名称:ibos,代码行数:23,代码来源:TypeController.php

示例8: actionImport

 public function actionImport()
 {
     $id = EnvUtil::getRequest("formid");
     $catId = EnvUtil::getRequest("catid");
     if (EnvUtil::submitCheck("formhash")) {
         $fileName = $_FILES["import"]["name"];
         $fileExt = StringUtil::getFileExt($fileName);
         if (!in_array($fileExt, array("txt", "htm", "html"))) {
             echo "<script type='text/javascript'>parent.Ui.alert('" . Ibos::lang("Form import desc") . "');</script>";
         } else {
             $upload = FileUtil::getUpload($_FILES["import"]);
             $upload->save();
             $files = $upload->getAttach();
             $file = $files["target"];
             $inajax = 0;
             if (empty($id)) {
                 $name = strstr($files["name"], ".", true);
                 $inajax = 1;
                 $id = FlowFormType::model()->quickAdd($name, $catId);
             }
             WfFormUtil::import($id, $file);
             $nextOpt = $_POST["nextopt"];
             $exec = "";
             if ($nextOpt == "edit") {
                 $param = sprintf("{'formid':'%d','inajax':%d}", $id, $inajax);
                 $exec = "parent.Wfs.formItem.edit({$param});";
             } elseif ($nextOpt == "design") {
                 $param = sprintf("{'formid':'%d'}", $id);
                 $exec = "parent.Wfs.formItem.design({$param});";
             }
             $this->ajaxReturn("<script type='text/javascript'>parent.Ui.tip('" . Ibos::lang("Import success") . "', 'success');{$exec}parent.Ui.getDialog('d_import_form').close();</script>", "eval");
         }
     }
     $lang = Ibos::getLangSources();
     $this->renderPartial("import", array("lang" => $lang, "id" => $id, "catid" => $catId));
 }
开发者ID:AxelPanda,项目名称:ibos,代码行数:36,代码来源:FormtypeController.php

示例9: actionUploadIcon

 public function actionUploadIcon()
 {
     $upload = FileUtil::getUpload($_FILES["Filedata"]);
     if (!$upload->save()) {
         $this->ajaxReturn(array("msg" => Ibos::lang("Save failed", "message"), "isSuccess" => false));
     } else {
         $info = $upload->getAttach();
         $file = FileUtil::getAttachUrl() . "/" . $info["type"] . "/" . $info["attachment"];
         $fileUrl = FileUtil::fileName($file);
         $tempSize = FileUtil::imageSize($fileUrl);
         if ($tempSize[0] < 64 || $tempSize[1] < 64) {
             $this->ajaxReturn(array("msg" => Ibos::lang("Icon size error"), "isSuccess" => false));
         }
         $this->ajaxReturn(array("imgurl" => $fileUrl, "aid" => $fileUrl, "name" => $info["name"], "isSuccess" => true));
     }
 }
开发者ID:AxelPanda,项目名称:ibos,代码行数:16,代码来源:QuicknavController.php

示例10: uploadAvatar

 private function uploadAvatar()
 {
     $upload = FileUtil::getUpload($_FILES["Filedata"]);
     if (!$upload->save()) {
         $this->ajaxReturn(array("msg" => Ibos::lang("Save failed", "message"), "IsSuccess" => false));
     } else {
         $info = $upload->getAttach();
         $file = FileUtil::getAttachUrl() . "/" . $info["type"] . "/" . $info["attachment"];
         $fileUrl = FileUtil::fileName($file);
         $tempSize = FileUtil::imageSize($fileUrl);
         if ($tempSize[0] < 180 || $tempSize[1] < 180) {
             $this->ajaxReturn(array("msg" => Ibos::lang("Avatar size error"), "IsSuccess" => false), "json");
         }
         Ibos::import("ext.ThinkImage.ThinkImage", true);
         $imgObj = new ThinkImage(THINKIMAGE_GD);
         $imgTemp = $imgObj->open($fileUrl);
         $params = array("w" => $imgTemp->width(), "h" => $imgTemp->height(), "x" => "0", "y" => "0");
         if ($params["h"] < $params["w"]) {
             $params["x"] = ($params["w"] - $params["h"]) / 2;
             $params["w"] = $params["h"];
         } else {
             $params["y"] = ($params["h"] - $params["w"]) / 2;
             $params["h"] = $params["w"];
         }
         $imgObj->open($fileUrl)->crop($params["w"], $params["h"], $params["x"], $params["y"])->save($fileUrl);
         $this->ajaxReturn(array("data" => $fileUrl, "file" => $fileUrl, "IsSuccess" => true));
     }
 }
开发者ID:AxelPanda,项目名称:ibos,代码行数:28,代码来源:DefaultController.php


注:本文中的FileUtil::getUpload方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。