本文整理汇总了PHP中upload_manager::original_filename_extension方法的典型用法代码示例。如果您正苦于以下问题:PHP upload_manager::original_filename_extension方法的具体用法?PHP upload_manager::original_filename_extension怎么用?PHP upload_manager::original_filename_extension使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类upload_manager
的用法示例。
在下文中一共展示了upload_manager::original_filename_extension方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save_uploaded_file
/**
* Processes a newly uploaded file, copies it to disk, and creates
* a new artefact object.
* Takes the name of a file input.
* Returns false for no errors, or a string describing the error.
*/
public static function save_uploaded_file($inputname, $data)
{
require_once 'uploadmanager.php';
$um = new upload_manager($inputname);
if ($error = $um->preprocess_file()) {
throw new UploadException($error);
}
$size = $um->file['size'];
if (!empty($data->owner)) {
global $USER;
if ($data->owner == $USER->get('id')) {
$owner = $USER;
} else {
$owner = new User();
$owner->find_by_id($data->owner);
}
if (!$owner->quota_allowed($size)) {
throw new QuotaExceededException(get_string('uploadexceedsquota', 'artefact.file'));
}
}
$data->size = $size;
$data->filetype = $um->file['type'];
$data->oldextension = $um->original_filename_extension();
$f = self::new_file($um->file['tmp_name'], $data);
$f->commit();
$id = $f->get('id');
// Save the file using its id as the filename, and use its id modulo
// the number of subdirectories as the directory name.
if ($error = $um->save_file(self::get_file_directory($id), $id)) {
$f->delete();
throw new UploadException($error);
} else {
if ($owner) {
$owner->quota_add($size);
$owner->commit();
}
}
return $id;
}
示例2: add_feedback_form_submit
function add_feedback_form_submit(Pieform $form, $values)
{
global $view, $artefact, $USER;
$data = new StdClass();
$data->view = $view->get('id');
if ($artefact) {
$data->artefact = $artefact->get('id');
$table = 'artefact_feedback';
} else {
$table = 'view_feedback';
}
$data->message = $values['message'];
$data->public = (int) $values['ispublic'];
$data->author = $USER->get('id');
if (!$data->author) {
unset($data->author);
$data->authorname = $values['authorname'];
}
$data->ctime = db_format_timestamp(time());
db_begin();
if (is_array($values['attachment'])) {
require_once get_config('libroot') . 'group.php';
require_once get_config('libroot') . 'uploadmanager.php';
safe_require('artefact', 'file');
$groupid = $view->get('submittedgroup');
if (group_user_can_assess_submitted_views($groupid, $USER->get('id'))) {
$um = new upload_manager('attachment');
if ($error = $um->preprocess_file()) {
throw new UploadException($error);
}
$owner = $view->get('owner');
$ownerlang = get_user_language($owner);
$folderid = ArtefactTypeFolder::get_folder_id(get_string_from_language($ownerlang, 'feedbackattachdirname', 'view'), get_string_from_language($ownerlang, 'feedbackattachdirdesc', 'view'), null, true, $owner);
$attachment = (object) array('owner' => $owner, 'parent' => $folderid, 'title' => ArtefactTypeFileBase::get_new_file_title($values['attachment']['name'], $folderid, $owner), 'size' => $values['attachment']['size'], 'filetype' => $values['attachment']['type'], 'oldextensin' => $um->original_filename_extension(), 'description' => get_string_from_language($ownerlang, 'feedbackonviewbytutorofgroup', 'view', $view->get('title'), display_name($USER), get_field('group', 'name', 'id', $groupid)));
try {
$data->attachment = ArtefactTypeFile::save_uploaded_file('attachment', $attachment);
} catch (QuotaExceededException $e) {
}
}
}
insert_record($table, $data, 'id', true);
require_once 'activity.php';
unset($data->id);
activity_occurred('feedback', $data);
db_commit();
if ($artefact) {
$goto = get_config('wwwroot') . 'view/artefact.php?artefact=' . $artefact->get('id') . '&view=' . $view->get('id');
} else {
$goto = get_config('wwwroot') . 'view/view.php?id=' . $view->get('id');
}
$form->reply(PIEFORM_OK, array('message' => get_string('feedbacksubmitted', 'view'), 'goto' => $goto));
}