當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。