本文整理汇总了PHP中FileUtil::getAttachUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP FileUtil::getAttachUrl方法的具体用法?PHP FileUtil::getAttachUrl怎么用?PHP FileUtil::getAttachUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileUtil
的用法示例。
在下文中一共展示了FileUtil::getAttachUrl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDocFile
private function getDocFile($var)
{
if ($var["isNew"]) {
$typeId = AttachUtil::attachType($var["param"]["filetype"], "id");
$map = array(self::DOC_WORD => array("fileName" => $var["lang"]["New doc"] . ".doc", "fileUrl" => self::OFFICE_PATH . "new.doc", "typeId" => self::DOC_WORD), self::DOC_EXCEL => array("fileName" => $var["lang"]["New excel"] . ".xls", "fileUrl" => self::OFFICE_PATH . "new.doc", "typeId" => self::DOC_WORD), self::DOC_PPT => array("fileName" => $var["lang"]["New ppt"] . ".ppt", "fileUrl" => self::OFFICE_PATH . "new.ppt", "typeId" => self::DOC_WORD));
return $map[$typeId];
} else {
return array("typeId" => AttachUtil::attachType(StringUtil::getFileExt($var["attach"]["attachment"]), "id"), "fileName" => $var["attach"]["filename"], "fileUrl" => FileUtil::fileName(FileUtil::getAttachUrl() . "/" . $var["attach"]["attachment"]));
}
}
示例2: makeThumb
public static function makeThumb($attach, $width, $height)
{
$attachUrl = FileUtil::getAttachUrl();
$file = sprintf("%s/%s", $attachUrl, $attach["attachment"]);
$fileext = StringUtil::getFileExt($file);
$thumbName = self::getThumbName($attach, $width, $height);
if (LOCAL) {
$res = ImageUtil::thumb2($file, $thumbName, "", $width, $height);
} else {
$tempFile = FileUtil::getTempPath() . "tmp." . $fileext;
$orgImgname = Ibos::engine()->IO()->file()->fetchTemp(FileUtil::fileName($file), $fileext);
ImageUtil::thumb2($orgImgname, $tempFile, "", $width, $height);
FileUtil::createFile($thumbName, file_get_contents($tempFile));
}
return $thumbName;
}
示例3: 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));
}
}
示例4: upload
public function upload()
{
$uid = intval(EnvUtil::getRequest("uid"));
$this->upload->save();
$attach = $this->upload->getAttach();
$attachment = $attach["type"] . "/" . $attach["attachment"];
$data = array("dateline" => TIMESTAMP, "filename" => $attach["name"], "filesize" => $attach["size"], "attachment" => $attachment, "isimage" => $attach["isimage"], "uid" => $uid);
$aid = Attachment::model()->add(array("uid" => $uid, "tableid" => 127), true);
$data["aid"] = $aid;
AttachmentUnused::model()->add($data);
$file["aid"] = $aid;
$file["name"] = $attach["name"];
$file["url"] = FileUtil::fileName(FileUtil::getAttachUrl() . "/" . $attachment);
if (!empty($file) && is_array($file)) {
return CJSON::encode($file);
} else {
return CJSON::encode(array("aid" => 0, "url" => 0, "name" => 0));
}
}
示例5: download
public function download($attach, $downloadInfo = array())
{
$file = FileUtil::getAttachUrl() . "/" . $attach["attachment"];
if (file_exists($file)) {
if (Ibos::app()->browser->name == "msie" || Ibos::app()->browser->getVersion() == "10.0" || Ibos::app()->browser->getVersion() == "11.0") {
$usingIe = true;
} else {
$usingIe = false;
}
$typeArr = array("1" => "application/octet-stream", "3" => "application/msword", "4" => "application/msexcel", "5" => "application/mspowerpoint", "7" => "application/octet-stream", "8" => "application/x-shockwave-flash", "10" => "application/pdf");
$attachType = AttachUtil::Attachtype(StringUtil::getFileExt($attach["filename"]), "id");
$content = false;
if (isset($downloadInfo["directView"])) {
if (!in_array($attachType, array("1", "7", "8", "10"))) {
$content = true;
}
$contentType = $typeArr[$attachType];
} else {
if (in_array($attachType, array("3", "4", "5")) && $usingIe) {
$contentType = $typeArr[$attachType];
} else {
$content = 1;
$contentType = "application/octet-stream";
}
}
ob_end_clean();
header("Cache-control: private");
header("Content-type: {$contentType}");
header("Accept-Ranges: bytes");
header("Content-Length: " . sprintf("%u", $this->fileSize($file)));
if ($usingIe) {
$attach["filename"] = urlencode($attach["filename"]);
}
if ($content) {
header("Content-Disposition: attachment; filename=\"" . $attach["filename"] . "\"");
} else {
header("Content-Disposition: filename=\"" . $attach["filename"] . "\"");
}
Attachment::model()->updateDownload($attach["aid"]);
readfile($file);
exit;
}
}
示例6: 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);
}
}
}
示例7: 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");
}
}
示例8: imguploadProcessor
public function imguploadProcessor($item, $readOnly)
{
$imgWidth = $item["data-width"];
$imgHeight = $item["data-height"];
$value = $this->getValue($item);
if ($value !== "") {
$attach = AttachmentN::model()->fetch(sprintf("rid:%d", $this->run->runid), $value);
$imgSrc = FileUtil::fileName(FileUtil::getAttachUrl() . "/" . $attach["attachment"]);
$imgID = $value;
} else {
$imgSrc = "";
$imgID = "";
}
$bg = Ibos::app()->assetManager->getAssetsUrl("workflow") . "/image/pic_upload.png";
if ($readOnly) {
$read = 1;
} else {
$read = 0;
}
$eleout = "\t\t\t\t<div data-item=\"imgupload\" data-width=\"{$imgWidth}\" data-height=\"{$imgHeight}\" data-id=\"{$item["itemid"]}\" data-bg=\"{$bg}\" data-read=\"{$read}\" data-src=\"{$imgSrc}\">\r\n\t\t\t\t\t<input type=\"hidden\" name=\"imgid_{$item["itemid"]}\" value=\"{$imgID}\" />\r\n\t\t\t\t</div>";
return $eleout;
}
示例9: checkDirExists
protected function checkDirExists($module, $ymDir, $dayDir)
{
$type = $this->checkDirType($module);
$baseDir = FileUtil::getAttachUrl();
$dirs = $baseDir . "/" . $type . "/" . $ymDir . "/" . $dayDir;
$res = is_dir($dirs);
if (!$res) {
$res = FileUtil::makeDirs($dirs);
}
return $res;
}
示例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));
}
}
示例11: actionEdit
public function actionEdit()
{
$op = EnvUtil::getRequest("op");
$resumeid = EnvUtil::getRequest("resumeid");
if (empty($op)) {
$op = "default";
}
if (!in_array($op, array("default", "update", "mark", "status")) || empty($resumeid)) {
$this->error(Ibos::lang("Parameters error", "error"), $this->createUrl("resume/index"));
}
if ($op == "default") {
$detail = ResumeDetail::model()->fetch("resumeid=:resumeid", array(":resumeid" => $resumeid));
$detail["birthday"] = date("Y-m-d", $detail["birthday"]);
$detail["status"] = Resume::model()->fetchStatusByResumeid($detail["resumeid"]);
$avatarid = $detail["avatarid"];
if (empty($avatarid)) {
$detail["avatarUrl"] = "";
} else {
$avatar = AttachUtil::getAttachData($avatarid);
$detail["avatarUrl"] = FileUtil::fileName(FileUtil::getAttachUrl() . "/" . $avatar[$avatarid]["attachment"]);
}
if (!empty($detail["attachmentid"])) {
$detail["attach"] = AttachUtil::getAttach($detail["attachmentid"]);
}
$data = array("sidebar" => $this->getSidebar(), "resumeDetail" => $detail, "dashboardConfig" => $this->getDashboardConfig(), "uploadConfig" => AttachUtil::getUploadConfig());
$data["dashboardConfigToJson"] = CJSON::encode($data["dashboardConfig"]);
$regulars = Regular::model()->fetchAll();
$data["regulars"] = CJSON::encode($regulars);
$this->setPageTitle(Ibos::lang("Edit resume"));
$this->setPageState("breadCrumbs", array(array("name" => Ibos::lang("Recruitment management"), "url" => $this->createUrl("resume/index")), array("name" => Ibos::lang("Talent management"), "url" => $this->createUrl("resume/index")), array("name" => Ibos::lang("Edit resume"))));
$this->render("edit", $data);
} else {
$this->{$op}();
}
}
示例12: 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;
}
}
示例13: getAttach
public static function getAttach($aid, $down = true, $officeDown = true, $edit = false, $delete = false, $getRealAddress = false)
{
$attach = array();
if (!empty($aid)) {
$data = self::getAttachData($aid);
}
$urlManager = Ibos::app()->urlManager;
foreach ($data as $id => &$val) {
$val["date"] = ConvertUtil::formatDate($val["dateline"], "u");
$val["filetype"] = StringUtil::getFileExt($val["filename"]);
$val["filesize"] = ConvertUtil::sizeCount($val["filesize"]);
if ($getRealAddress) {
$val["attachment"] = FileUtil::getAttachUrl() . "/" . $val["attachment"];
}
$val["filename"] = trim($val["filename"]);
$val["delete"] = $delete;
$val["down"] = $down;
$val["down_office"] = $officeDown;
$val["edit"] = $edit;
$val["iconsmall"] = self::attachType($val["filetype"], "smallicon");
$val["iconbig"] = self::attachType($val["filetype"], "bigicon");
$idString = self::getAttachStr($id, $val["tableid"]);
$val["openurl"] = $urlManager->createUrl("main/attach/open", array("id" => $idString));
if ($val["down"]) {
$val["downurl"] = $urlManager->createUrl("main/attach/download", array("id" => $idString));
}
$inOfficeRange = in_array(self::attachType($val["filetype"], "id"), range(3, 5));
if ($inOfficeRange && $val["down_office"]) {
$val["officereadurl"] = "http://view.officeapps.live.com/op/view.aspx?src=" . urlencode(Ibos::app()->setting->get("siteurl") . FileUtil::getAttachUrl() . "/" . $val["attachment"]);
}
if ($inOfficeRange && $val["edit"]) {
$val["officeediturl"] = $urlManager->createUrl("main/attach/office", array("id" => self::getAttachStr($aid, $val["tableid"], array("filetype" => $val["filetype"], "op" => "edit"))));
}
}
return $data;
}
示例14: 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));
}
}
示例15: sendWebMail
public static function sendWebMail($toUser, $body, $web)
{
$user = User::model()->fetchByUid($web["uid"]);
$password = StringUtil::authCode($web["password"], "DECODE", $user["salt"]);
$mailer = Yii::createComponent("application.modules.email.extensions.mailer.EMailer");
$mailer->IsSMTP();
$mailer->SMTPDebug = 0;
$mailer->Host = $web["smtpserver"];
$mailer->Port = $web["smtpport"];
$mailer->CharSet = "UTF-8";
if ($web["smtpssl"]) {
$mailer->SMTPSecure = "ssl";
}
$mailer->SMTPAuth = true;
$mailer->Username = $web["username"];
$mailer->Password = $password;
$mailer->setFrom($web["address"], $web["nickname"]);
foreach (explode(";", $toUser) as $address) {
$mailer->addAddress($address);
}
$mailer->Subject = $body["subject"];
$mailer->msgHTML($body["content"]);
$mailer->AltBody = "This is a plain-text message body";
if (!empty($body["attachmentid"])) {
$attachs = AttachUtil::getAttachData($body["attachmentid"]);
$attachUrl = FileUtil::getAttachUrl();
foreach ($attachs as $attachment) {
$url = $attachUrl . "/" . $attachment["attachment"];
if (LOCAL) {
$mailer->addAttachment($url, $attachment["filename"]);
} else {
$temp = Ibos::engine()->IO()->file()->fetchTemp($url);
$mailer->addAttachment($temp, $attachment["filename"]);
}
}
}
$status = $mailer->send();
if ($status) {
return true;
} else {
return $mailer->ErrorInfo;
}
}