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


PHP AttachmentFile::upload方法代码示例

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


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

示例1: uploadAttachments

 function uploadAttachments($files)
 {
     $i = 0;
     foreach ($files as $file) {
         if (($fileId = is_numeric($file) ? $file : AttachmentFile::upload($file)) && is_numeric($fileId)) {
             $sql = 'INSERT INTO ' . FAQ_ATTACHMENT_TABLE . ' SET faq_id=' . db_input($this->getId()) . ', file_id=' . db_input($fileId);
             if (db_query($sql)) {
                 $i++;
             }
         }
     }
     if ($i) {
         $this->reload();
     }
     return $i;
 }
开发者ID:pkdevboxy,项目名称:osTicket-1.7,代码行数:16,代码来源:class.faq.php

示例2: uploadFile

 /**
  * Called from FileUploadWidget::getValue() when manual upload is used
  * for browsers which do not support the HTML5 way of uploading async.
  */
 function uploadFile($file)
 {
     if (!$this->isValidFileType($file['name'], $file['type'])) {
         throw new FileUploadError(__('File type is not allowed'));
     }
     $config = $this->getConfiguration();
     if ($file['size'] > $config['size']) {
         throw new FileUploadError(__('File size is too large'));
     }
     return AttachmentFile::upload($file);
 }
开发者ID:gizur,项目名称:osticket,代码行数:15,代码来源:class.forms.php

示例3: upload

 function upload($files, $inline = false)
 {
     $i = array();
     if (!is_array($files)) {
         $files = array($files);
     }
     foreach ($files as $file) {
         if (($fileId = is_numeric($file) ? $file : AttachmentFile::upload($file)) && is_numeric($fileId)) {
             $sql = 'INSERT INTO ' . ATTACHMENT_TABLE . ' SET `type`=' . db_input($this->getType()) . ',object_id=' . db_input($this->getId()) . ',file_id=' . db_input($fileId) . ',inline=' . db_input($inline ? 1 : 0);
             // File may already be associated with the draft (in the
             // event it was deleted and re-added)
             if (db_query($sql, function ($errno) {
                 return $errno != 1062;
             }) || db_errno() == 1062) {
                 $i[] = $fileId;
             }
         }
     }
     return $i;
 }
开发者ID:ed00m,项目名称:osTicket-1.8,代码行数:20,代码来源:class.attachment.php

示例4: uploadAttachments

 function uploadAttachments($files, $refid, $type)
 {
     $uploaded = array();
     foreach ($files as $file) {
         if (($fileId = is_numeric($file) ? $file : AttachmentFile::upload($file)) && is_numeric($fileId)) {
             if ($this->saveAttachment($fileId, $refid, $type)) {
                 $uploaded[] = $fileId;
             }
         }
     }
     return $uploaded;
 }
开发者ID:ryan1432,项目名称:osTicket-1.7fork,代码行数:12,代码来源:class.ticket.php

示例5: uploadFiles

 function uploadFiles($files)
 {
     if (!$files || !is_array($files)) {
         return false;
     }
     $uploaded = array();
     foreach ($files as $file) {
         if ($file['error'] && $file['error'] == UPLOAD_ERR_NO_FILE) {
             continue;
         }
         if (!$file['error'] && ($id = AttachmentFile::upload($file)) && $this->saveAttachment($id)) {
             $uploaded[] = $id;
         } else {
             if (!$file['error']) {
                 $error = sprintf(__('Unable to upload file - %s'), $file['name']);
             } elseif (is_numeric($file['error'])) {
                 $error = 'Error #' . $file['error'];
             } else {
                 $error = $file['error'];
             }
             /*
               Log the error as an internal note.
               XXX: We're doing it here because it will eventually become a thread post comment (hint: comments coming!)
               XXX: logNote must watch for possible loops
             */
             $this->getTicket()->logNote(__('File Upload Error'), $error, 'SYSTEM', false);
         }
     }
     return $uploaded;
 }
开发者ID:CarlosAvilesMx,项目名称:CarlosAviles.Mx,代码行数:30,代码来源:class.thread.php

示例6: uploadAttachments

 function uploadAttachments($files, $refid, $type)
 {
     global $ost;
     $uploaded = array();
     foreach ($files as $file) {
         if (!$file['error'] && ($id = AttachmentFile::upload($file)) && $this->saveAttachment($id, $refid, $type)) {
             $uploaded[] = $id;
         } elseif ($file['error'] != UPLOAD_ERR_NO_FILE) {
             // log file upload errors as interal notes + syslog debug.
             if ($file['error'] && gettype($file['error']) == 'string') {
                 $error = $file['error'];
             } else {
                 $error = 'Error #' . $file['error'];
             }
             $this->postNote('File Upload Error', $error, false);
             $ost->logDebug('File Upload Error (Ticket #' . $this->getExtId() . ')', $error);
         }
     }
     return $uploaded;
 }
开发者ID:nunomartins,项目名称:osTicket-1.7,代码行数:20,代码来源:class.ticket.php


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