本文整理汇总了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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}