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; }
/** * 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); }
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; }
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; }
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; }
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; }