• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Attachment类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: recordInbound

 function recordInbound()
 {
     $strJson = file_get_contents("php://input");
     try {
         $arrResponse = Convert::json2array($strJson);
         if ($savedMessage = PostmarkMessage::get()->filter('MessageID', $arrResponse['MessageID'])->first()) {
             return;
         }
         $hash = $arrResponse['ToFull'][0]['MailboxHash'];
         $hashParts = explode('+', $hash);
         $lastMessage = PostmarkMessage::get()->filter(array('UserHash' => $hashParts[0], 'MessageHash' => $hashParts[1]))->first();
         $fromCustomer = PostmarkHelper::find_or_make_client($arrResponse['From']);
         $inboundSignature = null;
         if ($lastMessage) {
             $inboundSignature = $lastMessage->From();
         } else {
             if (!$lastMessage && isset($arrResponse['To'])) {
                 $inboundSignature = PostmarkSignature::get()->filter('Email', $arrResponse['To'])->first();
             }
         }
         if (!$inboundSignature) {
             $inboundSignature = PostmarkSignature::get()->filter('IsDefault', 1)->first();
         }
         $message = new PostmarkMessage(array('Subject' => $arrResponse['Subject'], 'Message' => $arrResponse['HtmlBody'], 'ToID' => 0, 'MessageID' => $arrResponse['MessageID'], 'InReplyToID' => $lastMessage ? $lastMessage->ID : 0, 'FromCustomerID' => $fromCustomer ? $fromCustomer->ID : 0, 'InboundToID' => $inboundSignature ? $inboundSignature->ID : 0));
         $message->write();
         if (isset($arrResponse['Attachments']) && count($arrResponse['Attachments'])) {
             foreach ($arrResponse['Attachments'] as $attachment) {
                 $attachmentObject = new Attachment(array('Content' => $attachment['Content'], 'FileName' => $attachment['Name'], 'ContentType' => $attachment['ContentType'], 'Length' => $attachment['ContentLength'], 'ContentID' => $attachment['ContentID'], 'PostmarkMessageID' => $message->ID));
                 $attachmentObject->write();
             }
         }
     } catch (Exception $e) {
     }
     return 'OK';
 }
开发者ID:bueckl,项目名称:postmarkedapp,代码行数:35,代码来源:PostmarkNotifier.php


示例2: store

 public function store($notebookId, $noteId, $versionId)
 {
     $note = self::getNote($notebookId, $noteId, $versionId);
     if ($note->pivot->umask < PaperworkHelpers::UMASK_READWRITE) {
         return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_ERROR, array('message' => 'Permission Error'));
     }
     if (Input::hasFile('file') && Input::file('file')->isValid() || Input::json() != null && Input::json() != "") {
         $fileUpload = null;
         $newAttachment = null;
         if (Input::hasFile('file')) {
             $fileUpload = Input::file('file');
             $newAttachment = new Attachment(array('filename' => $fileUpload->getClientOriginalName(), 'fileextension' => $fileUpload->getClientOriginalExtension(), 'mimetype' => $fileUpload->getMimeType(), 'filesize' => $fileUpload->getSize()));
         } else {
             $fileUploadJson = Input::json();
             $fileUpload = base64_decode($fileUploadJson->get('file'));
             $newAttachment = new Attachment(array('filename' => $fileUploadJson->get('clientOriginalName'), 'fileextension' => $fileUploadJson->get('clientOriginalExtension'), 'mimetype' => $fileUploadJson->get('mimeType'), 'filesize' => count($fileUpload)));
         }
         $newAttachment->save();
         // Move file to (default) /app/storage/attachments/$newAttachment->id/$newAttachment->filename
         $destinationFolder = Config::get('paperwork.attachmentsDirectory') . '/' . $newAttachment->id;
         if (!File::makeDirectory($destinationFolder, 0700)) {
             $newAttachment->delete();
             return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_ERROR, array('message' => 'Internal Error'));
         }
         // Get Version with versionId
         //$note = self::getNote($notebookId, $noteId, $versionId);
         $tmp = $note ? $note->version()->first() : null;
         $version = null;
         if (is_null($tmp)) {
             $newAttachment->delete();
             File::deleteDirectory($destinationFolder);
             return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_NOTFOUND, array('message' => 'version->first'));
         }
         while (!is_null($tmp)) {
             if ($tmp->id == $versionId || $versionId == 0) {
                 $version = $tmp;
                 break;
             }
             $tmp = $tmp->previous()->first();
         }
         if (is_null($version)) {
             $newAttachment->delete();
             File::deleteDirectory($destinationFolder);
             return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_NOTFOUND, array('message' => 'version'));
         }
         if (Input::hasFile('file')) {
             $fileUpload->move($destinationFolder, $fileUpload->getClientOriginalName());
         } else {
             file_put_contents($destinationFolder . '/' . $fileUploadJson->get('clientOriginalName'), $fileUpload);
         }
         $version->attachments()->attach($newAttachment);
         // Let's push that parsing job, which analyzes the document, converts it if needed and parses the crap out of it.
         Queue::push('DocumentParserWorker', array('user_id' => Auth::user()->id, 'document_id' => $newAttachment->id));
         return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_SUCCESS, $newAttachment);
     } else {
         return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_ERROR, array('message' => 'Invalid input'));
     }
 }
开发者ID:netesheng,项目名称:paperwork,代码行数:58,代码来源:ApiAttachmentsController.php


示例3: deleteSelection

 public function deleteSelection($attachments)
 {
     $return = 1;
     foreach ($attachments as $id_attachment) {
         $attachment = new Attachment((int) $id_attachment);
         $return &= $attachment->delete();
     }
     return $return;
 }
开发者ID:hecbuma,项目名称:quali-fisioterapia,代码行数:9,代码来源:Attachment.php


示例4: createTables

 /**
  * We need a table for the attachments if it doesnt exist TBL_ATTACHMENT
  */
 function createTables()
 {
     $tables = array();
     if ($this->verifyTable('TBL_ATTACHMENT')) {
         $obj = new Attachment($this->db);
         $tables[] = $obj->generateCreateTables();
     }
     $tables = $this->addLinkTables($tables);
     $this->execute($tables);
 }
开发者ID:Barthak,项目名称:voodoo,代码行数:13,代码来源:AttachmentSetup.php


示例5: LoadAll

 public static function LoadAll()
 {
     $sql = sprintf("SELECT * FROM %s;", self::TABLE_NAME);
     $result = LoadDriver::query($sql);
     $coll = new BaseEntityCollection();
     while ($data = mysql_fetch_assoc($result)) {
         $tObj = new Attachment();
         $tObj->materilize($data);
         $coll->addItem($tObj);
     }
     return $coll;
 }
开发者ID:laiello,项目名称:schematical-open-source,代码行数:12,代码来源:Attachment.class.php


示例6: getData

 /**
  * Get message data
  *
  * @return array
  */
 public function getData()
 {
     $res = ['recipient' => ['id' => $this->recipient]];
     $attachment = new Attachment(Attachment::TYPE_AUDIO);
     if (strpos($this->text, 'http://') === 0 || strpos($this->text, 'https://') === 0) {
         $attachment->setPayload(array('url' => $this->text));
     } else {
         $attachment->setFileData($this->getCurlValue($this->text, mime_content_type($this->text), basename($this->text)));
     }
     $res['message'] = $attachment->getData();
     return $res;
 }
开发者ID:pimax,项目名称:fb-messenger-php,代码行数:17,代码来源:AudioMessage.php


示例7: configure

 public function configure()
 {
     if ($category = $this->getObject()->getCategory()) {
         $this->embedForm('category', new CategoryForm($this->getObject()->getCategory()));
     }
     if ($this->getOption('with_attachment')) {
         $attachment = new Attachment();
         $attachment->setArticle($this->object);
         $attachmentForm = new AttachmentForm($attachment);
         unset($attachmentForm['article_id']);
         $this->embedForm('attachment', $attachmentForm);
     }
 }
开发者ID:xfifix,项目名称:symfony-1.4,代码行数:13,代码来源:ArticleForm.class.php


示例8: processRow

 /**
  * Process db row
  * @param array $row
  * @return array
  */
 public function processRow(array $row)
 {
     global $ADMIN;
     // edit link
     $row['file_name'] = sprintf('<a href="/%s/media-archive/edit-attachment.php?f_attachment_id=%d">%s</a>', $ADMIN, $row['id'], $row['file_name']);
     // human readable size
     $row['size_in_bytes'] = parent::FormatFileSize($row['size_in_bytes']);
     // yes/no disposition
     $row['content_disposition'] = empty($row['content_disposition']) ? getGS('Yes') : getGS('No');
     // get in use info
     $object = new Attachment($row['id']);
     $row['InUse'] = (int) $object->inUse();
     return array_values($row);
 }
开发者ID:nidzix,项目名称:Newscoop,代码行数:19,代码来源:MediaList.php


示例9: main_delete_attachment

 public function main_delete_attachment()
 {
     if (!isset($_GET['id'])) {
         error(__("No ID Specified"), __("An ID is required to delete an attachment.", "attachments"));
     }
     $attachment = new Attachment($_GET['id']);
     if ($attachment->no_results) {
         error(__("Error"), __("Invalid attachment ID specified.", "attachments"));
     }
     if (!$attachment->deletable()) {
         show_403(__("Access Denied"), __("You do not have sufficient privileges to delete this attachment.", "attachments"));
     }
     Attachment::delete($attachment->id);
     Flash::notice(__("Attachment deleted.", "attachments"), $_SESSION['redirect_to']);
 }
开发者ID:vito,项目名称:chyrp-site,代码行数:15,代码来源:attachments.php


示例10: actionPickAtt

 public function actionPickAtt()
 {
     $return_id = $_GET['return_id'];
     $rtype = $_GET['rtype'];
     $criteria = new CDbCriteria();
     if (isset($_GET['keyword'])) {
         $screen_name = trim($_GET['keyword']);
         $criteria->condition = 'screen_name like :screen_name';
         $criteria->params = array(':screen_name' => "%{$screen_name}%");
         $partial_tpl = '_att';
         //$atts = Attachment::model()->findAll($criteria);
         //$this->renderPartial('_att',array('return_id' => $return_id,'atts' => $atts,'rtype' => $rtype ),false,true);
     } else {
         $partial_tpl = 'pickatt';
         //$atts = Attachment::model()->findAll();
         //$this->renderPartial('pickatt',array('return_id' => $return_id,'atts' => $atts ,'rtype' => $rtype ),false,true);
     }
     $item_count = Attachment::model()->count($criteria);
     $page_size = 10;
     $pages = new CPagination($item_count);
     $pages->setPageSize($page_size);
     $pagination = new CLinkPager();
     $pagination->cssFile = false;
     $pagination->setPages($pages);
     $pagination->init();
     $criteria->limit = $page_size;
     $criteria->offset = $pages->offset;
     $select_pagination = new CListPager();
     $select_pagination->htmlOptions['onchange'] = "";
     $select_pagination->setPages($pages);
     $select_pagination->init();
     $atts = Attachment::model()->findAll($criteria);
     $this->renderPartial($partial_tpl, array('return_id' => $return_id, 'atts' => $atts, 'rtype' => $rtype, 'pagination' => $pagination, 'select_pagination' => $select_pagination), false, true);
 }
开发者ID:paranoidxc,项目名称:iwebhost,代码行数:34,代码来源:RelController.php


示例11: handleTreeEditPost

 private function handleTreeEditPost()
 {
     $request = Request::getInstance();
     $values = $request->getRequest(Request::POST);
     try {
         if (!$request->exists('tree_id')) {
             throw new Exception('Node ontbreekt.');
         }
         if (!$request->exists('tag')) {
             throw new Exception('Tag ontbreekt.');
         }
         $tree_id = intval($request->getValue('tree_id'));
         $tag = $request->getValue('tag');
         $key = array('tree_id' => $tree_id, 'tag' => $tag);
         if ($this->exists($key)) {
             $this->update($key, $values);
         } else {
             $this->insert($values);
         }
         $treeRef = new AttachmentTreeRef();
         $treeRef->delete($key);
         foreach ($values['ref_tree_id'] as $ref_tree_id) {
             $key['ref_tree_id'] = $ref_tree_id;
             $treeRef->insert($key);
         }
         viewManager::getInstance()->setType(ViewManager::ADMIN_OVERVIEW);
         $this->plugin->getReferer()->handleHttpGetRequest();
     } catch (Exception $e) {
         $template = new TemplateEngine();
         $template->setVariable('errorMessage', $e->getMessage(), false);
         $this->handleTreeEditGet(false);
     }
 }
开发者ID:rverbrugge,项目名称:dif,代码行数:33,代码来源:AttachmentHeadlines.php


示例12: createAttachment

 /**
  * Create Attachment instance and move file to attachmentsDirectory
  *
  * @param $data
  * @param $fileName
  * @param string $mime
  * @return \Attachment
  * @throws \Exception
  */
 protected function createAttachment($data, $fileName, $mime = '')
 {
     if (empty($mime)) {
         $f = finfo_open();
         $mime = finfo_buffer($f, $data, FILEINFO_MIME_TYPE);
     }
     $newAttachment = new \Attachment(array('filename' => $fileName, 'fileextension' => pathinfo($fileName, PATHINFO_EXTENSION), 'mimetype' => $mime, 'filesize' => strlen($data)));
     $newAttachment->save();
     $destinationFolder = \Config::get('paperwork.attachmentsDirectory') . '/' . $newAttachment->id;
     if (!\File::makeDirectory($destinationFolder, 0700)) {
         $newAttachment->delete();
         throw new \Exception('Error creating directory');
     }
     file_put_contents($destinationFolder . '/' . $fileName, $data);
     return $newAttachment;
 }
开发者ID:Liongold,项目名称:paperwork,代码行数:25,代码来源:AbstractImport.php


示例13: mutateAttribute

 public function mutateAttribute($key, $value)
 {
     preg_match('/(.*)_(image|file)(_la)?$/', $key, $matches);
     if (count($matches) > 0) {
         list($match_data, $field_name_prefix, $field_type) = $matches;
         $la_mode = count($matches) == 4;
         $field_name = "{$field_name_prefix}_{$field_type}_id";
         if (!$this->{$field_name}) {
             return null;
         }
         switch ($field_type) {
             case 'image':
                 $obj = Image::find($this->{$field_name});
                 break;
             case 'file':
                 $obj = Attachment::find($this->{$field_name});
                 break;
             default:
                 throw new \Exception("Unrecognized attachment type {$field_type}");
         }
         if (!$obj) {
             return null;
         }
         if ($la_mode) {
             // Recover image if missing from Laravel Admin
             $la_fpath = config('laravel-stapler.images.la_path') . "/{$obj->att_file_name}";
             if (!file_exists($la_fpath)) {
                 copy($obj->path('admin'), $la_fpath);
             }
             return $obj->att_file_name;
         }
         return $obj->att;
     }
     return parent::mutateAttribute($key, $value);
 }
开发者ID:benallfree,项目名称:laravel-stapler-images,代码行数:35,代码来源:AttachmentTrait.php


示例14: run

 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Attachment::create([]);
     }
 }
开发者ID:SenhorBardell,项目名称:yol,代码行数:7,代码来源:AttachmentsTableSeeder.php


示例15: actionRepairUpload

 public function actionRepairUpload()
 {
     $index = $this->request->getParam("selectedIndex");
     $pre_id = $this->request->getParam("upload_save_to_db_id");
     $inputFileName = "repair_attached_file" . $index;
     $attach = CUploadedFile::getInstanceByName($inputFileName);
     $retValue = "";
     if ($attach == null) {
         $retValue = "提示:不能上传空文件。";
     } else {
         if ($attach->size > 2000000) {
             $retValue = "提示:文件大小不能超过2M。";
         } else {
             $retValue = '恭喜,上传成功!';
             if ($pre_id == 0) {
                 $f = file_get_contents($attach->tempName);
                 $a = new Attachment();
                 $a->ref_type = "failParts";
                 $a->data = $f;
                 $a->file_path = $attach->name;
                 $a->save();
                 $cur_id = $a->id;
             } else {
                 $trans = Yii::app()->db->beginTransaction();
                 try {
                     $f = file_get_contents($attach->tempName);
                     $a = new Attachment();
                     $a->ref_type = "failParts";
                     $a->data = $f;
                     $a->file_path = $attach->name;
                     $a->save();
                     $cur_id = $a->id;
                     $pre = Attachment::model()->findByPk($pre_id);
                     $pre->delete();
                     $trans->commit();
                 } catch (Exception $e) {
                     $retValue = $e->getMessage();
                     $cur_id = 0;
                     $trans->rollback();
                 }
             }
             echo "<script type='text/javascript'>window.top.window.successUpload('{$retValue}',{$cur_id},{$index})</script>";
             exit;
         }
     }
     echo "<script type='text/javascript'>window.top.window.stopUpload('{$retValue}',{$index})</script>";
 }
开发者ID:Aaronwmc,项目名称:WindMill,代码行数:47,代码来源:MyUploadController.php


示例16: loadAttachment

 private function loadAttachment($attachmentId)
 {
     $attachment = Attachment::find($attachmentId);
     if (is_null($attachment)) {
         throw new Exception('Document parsing job #' . $this->job->getJobId() . ' contains an invalid document_id. Aborting.');
     }
     return $attachment;
 }
开发者ID:jinchen891021,项目名称:paperwork,代码行数:8,代码来源:DocumentParserWorker.php


示例17: fromResponse

 public static function fromResponse($data)
 {
     $array = [];
     foreach ($data as $update) {
         $array[] = Attachment::fromResponse($update);
     }
     return $array;
 }
开发者ID:veksa,项目名称:carrot-api,代码行数:8,代码来源:ArrayOfAttachment.php


示例18: a

 public function a()
 {
     $id = $this->request->param('ID');
     $attachment = Attachment::get()->filterAny(array('ID' => $id, 'ContentID' => $id))->first();
     if ($attachment) {
         return $attachment->returnToBrowser();
     }
     return $this->httpError(404);
 }
开发者ID:bueckl,项目名称:postmarkedapp,代码行数:9,代码来源:PostmarkAttachments.php


示例19: pdfMergeAttachmentAction

 public function pdfMergeAttachmentAction()
 {
     //this function is primarily used by other controllers so parameters here are not permitted from _GET and _POST do to possible injection into the xmlData arg which would be very hard to filter
     $request = $this->getRequest();
     $request->setParamSources(array());
     $attachmentReferenceId = preg_replace('/[^a-zA-Z0-9-]/', '', $this->_getParam('attachmentReferenceId'));
     $xmlData = $this->_getParam('xmlData');
     $attachment = new Attachment();
     $attachment->attachmentReferenceId = $attachmentReferenceId;
     //'ff560b50-75d0-11de-8a39-0800200c9a66' uuid for prescription pdf
     $attachment->populateWithAttachmentReferenceId();
     $db = Zend_Registry::get('dbAdapter');
     $sql = "select data from attachmentBlobs where attachmentId = " . $attachment->attachmentId;
     $stmt = $db->query($sql);
     $row = $stmt->fetch();
     $this->view->pdfBase64 = base64_encode($row['data']);
     $stmt->closeCursor();
     $this->view->xmlData = $xmlData;
     header('Content-type: application/vnd.adobe.xfdf');
 }
开发者ID:dragonlet,项目名称:clearhealth,代码行数:20,代码来源:PdfController.php


示例20: mdt_add_attachment

function mdt_add_attachment($id)
{
    try {
        require_once "Attachment.php";
        require_once "Image.php";
        require_once "Upload.php";
        $u = new Upload(FTP_CDN_HOST, FTP_CDN_USER, FTP_CDN_PASWD);
        $a = new Attachment($id);
        $i = new Image();
        $upload_dir = wp_upload_dir();
        $upload_dir = $upload_dir['baseurl'];
        $a->select();
        $u->sourceDir = UPLOAD_PATH . $a->year . '/' . $a->month;
        $u->destinyDir = '';
        $destiny = $u->setFtpDir($a->year, $a->month);
        //die(print_r(array($u->sourceDir.'/'.$a->guid['name'], $destiny.'/'.$a->guid['name'])));
        $u->put($u->sourceDir . '/' . $a->guid['name'], $destiny . '/' . $a->guid['name']);
        //die("end");
        foreach ($i->sizes as $k => $size) {
            $source = $u->sourceDir . '/' . $a->guid['name'];
            $file = $u->sourceDir . '/' . $a->guid['name'];
            if (in_array($k, array('medium', 'large'))) {
                $name = $i->defineImageName($source, $file, $size[0], $size[1], true);
            } else {
                list($width, $height) = $i->defineProportionalSize($source, $size[0], $size[1]);
                $name = $i->defineImageName($source, $file, $size[0], $size[1], false);
            }
            $file = $u->sourceDir . '/' . $name;
            if (!file_exists($file)) {
                $i->resize($source, $file, $size[0], $size[1], null, $k);
            }
            $u->put($file, $destiny . '/' . $name);
            //unlink($file);
        }
        //unlink($u->sourceDir.'/'.$a->guid['name']);
    } catch (Exception $e) {
        echo '<div class="error"><p>' . $e->getMessage() . '</p></div>';
    }
}
开发者ID:ricardo93borges,项目名称:mdt-upload,代码行数:39,代码来源:mdt-upload.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP AttachmentFile类代码示例发布时间:2022-05-23
下一篇:
PHP AssociationFactory类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap