本文整理汇总了PHP中upload_manager::get_new_filepath方法的典型用法代码示例。如果您正苦于以下问题:PHP upload_manager::get_new_filepath方法的具体用法?PHP upload_manager::get_new_filepath怎么用?PHP upload_manager::get_new_filepath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类upload_manager
的用法示例。
在下文中一共展示了upload_manager::get_new_filepath方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: gettext
if ($numicons >= $_SESSION['icon_quota']) {
$ok = false;
$messages[] = gettext("You have already met your icon quota. You must delete some icons before you can upload any new ones.");
}
}
require_once $CFG->dirroot . 'lib/uploadlib.php';
// TODO passing 0 as maxbytes here as icon_quota is based on number of icons
// so upload_manager will look at PHP settings instead.
// not ideal but as good as it can be for the now.
$um = new upload_manager('iconfile', false, true, false, 0, true);
$messages[] = gettext("Attempting to upload icon file ...");
$ul_username = run("users:id_to_name", $page_owner);
$upload_folder = $textlib->substr($ul_username, 0, 1);
$dir = $CFG->dataroot . "icons/" . $upload_folder . "/" . $ul_username . "/";
if ($ok = $um->process_file_uploads($dir)) {
if (!($imageattr = @getimagesize($um->get_new_filepath()))) {
$ok = false;
$messages[] = gettext("The uploaded icon file was invalid. Please ensure you are using JPEG, GIF or PNG files.");
}
}
if ($ok == true) {
if ($imageattr[0] > 100 || $imageattr[1] > 100) {
// $ok = false;
// $messages[] = gettext("The uploaded icon file was too large. Files must have maximum dimensions of 100x100.");
require_once $CFG->dirroot . 'lib/iconslib.php';
$phpThumb = new phpThumb();
// import default config
if (!empty($PHPTHUMB_CONFIG)) {
foreach ($PHPTHUMB_CONFIG as $key => $value) {
$keyname = 'config_' . $key;
$phpThumb->setParameter($keyname, $value);
示例2: pathinfo
$attachment = $course->id . '/' . $form->attachment;
$pathparts = pathinfo($form->attachment);
$attachname = $pathparts['basename'];
} else {
$form->error = get_string('attachmenterror', 'block_quickmail', $form->attachment);
}
}
} else {
require_once $CFG->libdir . '/uploadlib.php';
$um = new upload_manager('attachment', false, true, $course, false, 0, true);
// process the student posted attachment if it exists
if ($um->process_file_uploads('temp/block_quickmail')) {
// original name gets saved in the database
$form->attachment = $um->get_original_filename();
// check if file is there
if (file_exists($um->get_new_filepath())) {
// get path to the file without $CFG->dataroot
$attachment = 'temp/block_quickmail/' . $um->get_new_filename();
// get the new name (name may change due to filename collisions)
$attachname = $um->get_new_filename();
} else {
$form->error = get_string("attachmenterror", "block_quickmail", $form->attachment);
}
} else {
$form->attachment = '';
// no attachment
}
}
// no errors, then email
if (!isset($form->error)) {
$mailedto = array();
示例3: error
$template = get_record('assignment_uploadpdf_tmpl', 'id', $item->template);
if ($template && $template->course == 0 && !$caneditsite) {
error("No permission to edit site templates");
}
delete_records('assignment_uploadpdf_tmplitm', 'id', $itemid);
$itemid = 0;
}
}
} elseif ($uploadpreview) {
$partdest = $courseid . IMAGE_PATH;
$fulldest = $CFG->dataroot . '/' . $partdest;
check_dir_exists($fulldest);
require_once $CFG->dirroot . '/lib/uploadlib.php';
$um = new upload_manager('preview', false, false, $course, false, 0, true);
if ($um->process_file_uploads($partdest)) {
$fp = $um->get_new_filepath();
$fn = $um->get_new_filename();
require_once 'mypdflib.php';
$pdf = new MyPDFLib();
$pdf->load_pdf($fp);
$pdf->set_image_folder($fulldest);
$imagename = $pdf->get_image(1);
unlink($fp);
} else {
//echo 'No file uploaded';
//die;
}
} elseif ($duplicatetemplate) {
// Should not have access to the 'duplicate' button unless a template is selected
// but, just in case, we check here (but just do nothing if that is not the case)
if ($templateid != -1) {
示例4: gettext
function upload_foaf()
{
global $data, $CFG;
$action = optional_param('action');
if (!empty($action) && $action == "profile:foaf:upload" && logged_on && run("permissions:check", "profile")) {
require_once $CFG->dirroot . 'lib/uploadlib.php';
$um = new upload_manager('foaf_file', false, true, 0, true);
$dir = $CFG->dataroot . 'tmp/foaf/';
if (!$um->process_file_uploads($dir)) {
$messages[] = gettext("There was an error uploading the file. Possibly the file was too large, or the upload was interrupted.");
$messages[] = $um->get_errors();
return false;
}
$file = $um->get_new_filepath();
$foaf = @GetXMLTreeProfile($file);
$data['profile:preload'] = array();
if (isset($foaf['RDF:RDF'][0]['PERSON'][0]) && !isset($foaf['RDF:RDF'][0]['FOAF:PERSON'][0])) {
$foaf['RDF:RDF'][0]['FOAF:PERSON'][0] = $foaf['RDF:RDF'][0]['PERSON'][0];
}
if (isset($foaf['RDF:RDF'][0]['FOAF:PERSON'][0])) {
$foaf = $foaf['RDF:RDF'][0]['FOAF:PERSON'][0];
if (!empty($data['foaf:profile']) && sizeof($data['foaf:profile']) > 0) {
foreach ($data['foaf:profile'] as $foaf_element) {
$profile_value = addslashes($foaf_element[0]);
$foaf_name = $foaf_element[1];
$individual = $foaf_element[2];
$resource = $foaf_element[3];
if (isset($foaf[strtoupper($foaf_name)])) {
$values = $foaf[strtoupper($foaf_name)];
foreach ($values as $value) {
$thisvalue = "";
if (trim($value['VALUE']) != "") {
$thisvalue = trim($value['VALUE']);
} else {
if (isset($value['ATTRIBUTES']['DC:TITLE']) && trim($value['ATTRIBUTES']['DC:TITLE'] != "")) {
$thisvalue = trim($value['ATTRIBUTES']['DC:TITLE']);
} else {
if (isset($value['ATTRIBUTES']['RDF:RESOURCE']) && trim($value['ATTRIBUTES']['RDF:RESOURCE'] != "")) {
$thisvalue = trim($value['ATTRIBUTES']['RDF:RESOURCE']);
}
}
}
if ($thisvalue != "") {
if (!isset($data['profile:preload'][$profile_value])) {
$data['profile:preload'][$profile_value] = $thisvalue;
} else {
$data['profile:preload'][$profile_value] .= ", " . $thisvalue;
}
}
}
}
}
}
if (!empty($foaf['VCARD:ADR']) && sizeof($foaf['VCARD:ADR']) > 0) {
if (!empty($data['vcard:profile:adr']) && sizeof($data['vcard:profile:adr']) > 0) {
$foaf = $foaf['VCARD:ADR'][0];
foreach ($data['vcard:profile:adr'] as $foaf_element) {
$profile_value = addslashes($foaf_element[0]);
$foaf_name = $foaf_element[1];
$individual = $foaf_element[2];
$resource = $foaf_element[3];
if (isset($foaf[strtoupper($foaf_name)])) {
$values = $foaf[strtoupper($foaf_name)];
foreach ($values as $value) {
$thisvalue = "";
if (trim($value['VALUE']) != "") {
$thisvalue = trim($value['VALUE']);
} else {
if (isset($value['ATTRIBUTES']['DC:TITLE']) && trim($value['ATTRIBUTES']['DC:TITLE'] != "")) {
$thisvalue = trim($value['ATTRIBUTES']['DC:TITLE']);
} else {
if (isset($value['ATTRIBUTES']['RDF:RESOURCE']) && trim($value['ATTRIBUTES']['RDF:RESOURECE'] != "")) {
$thisvalue = trim($value['ATTRIBUTES']['DC:TITLE']);
}
}
}
if ($thisvalue != "") {
if (!isset($data['profile:preload'][$profile_value])) {
$data['profile:preload'][$profile_value] = $thisvalue;
} else {
$data['profile:preload'][$profile_value] .= ", " . $thisvalue;
}
}
}
}
}
}
}
$messages[] = gettext("Data from your FOAF file has been preloaded. You must click Save at the bottom of the page for the changes to take effect.");
} else {
$messages[] = gettext("Error: supplied file did not appear to be a FOAF file.");
}
}
return true;
}
示例5: stdClass
$category->id = 0;
}
$strsuccess = '';
if ($data = data_submitted()) {
include $CFG->libdir . '/filelib.php';
include $CFG->libdir . '/uploadlib.php';
// Process uploaded images or uploaded zip file.
$dir = $gallery->file_area($category->id);
$um = new upload_manager('userfile', false, true, $gallery->course, false, 0);
if ($um->process_file_uploads($dir)) {
$file = new stdClass();
$file->galleryid = $gallery->module->id;
$file->categoryid = $catid;
$file->userid = $USER->id;
$file->name = $um->get_new_filename();
$file->path = $um->get_new_filepath();
if (preg_match($GALLERY_ALLOWED_TYPES, $file->name)) {
// Check if uploaded file was a zip package.
$icon = mimeinfo('icon', $file->name);
if ($icon != 'zip.gif') {
// Single file.
$file->size = filesize($file->path);
$file->mime = mimeinfo('type', $file->name);
$fileinfo = getimagesize($file->path);
$file->width = $fileinfo[0];
$file->height = $fileinfo[1];
$file->timecreated = time();
$file->timemodified = time();
$gallery->check_dimensions($file);
$file->description = addslashes(trim(strip_tags($_POST['description'])));
$file->path = $gallery->get_file_path($file->path);
示例6: notify
function upload_file()
{
global $CFG, $USER;
$mode = optional_param('mode', '', PARAM_ALPHA);
$offset = optional_param('offset', 0, PARAM_INT);
$returnurl = 'view.php?id=' . $this->cm->id;
$filecount = $this->count_user_files($USER->id);
$submission = $this->get_submission($USER->id);
if (!$this->can_upload_file($submission)) {
$this->view_header(get_string('upload'));
notify(get_string('uploaderror', 'assignment'));
print_continue($returnurl);
$this->view_footer();
die;
}
$dir = $this->file_area_name($USER->id);
check_dir_exists($CFG->dataroot . '/' . $dir, true, true);
// better to create now so that student submissions do not block it later
require_once $CFG->dirroot . '/lib/uploadlib.php';
$um = new upload_manager('newfile', false, true, $this->course, false, $this->assignment->maxbytes, true);
if ($um->process_file_uploads($dir)) {
$fp = $um->get_new_filepath();
$fn = $um->get_new_filename();
if ($fp && $fn) {
$dest = $CFG->dataroot . '/' . $dir . '/' . sprintf('%02d', $filecount + 1) . '-' . $fn;
rename($fp, $dest);
}
$submission = $this->get_submission($USER->id, true);
//create new submission if needed
$updated = new object();
$updated->id = $submission->id;
$updated->timemodified = time();
if (update_record('assignment_submissions', $updated)) {
add_to_log($this->course->id, 'assignment', 'upload', 'view.php?a=' . $this->assignment->id, $this->assignment->id, $this->cm->id);
$submission = $this->get_submission($USER->id);
$this->update_grade($submission);
//$this->email_teachers($submission);
} else {
$new_filename = $um->get_new_filename();
$this->view_header(get_string('upload'));
notify(get_string('uploadnotregistered', 'assignment', $new_filename));
print_continue($returnurl);
$this->view_footer();
die;
}
redirect('view.php?id=' . $this->cm->id);
}
$this->view_header(get_string('upload'));
notify(get_string('uploaderror', 'assignment'));
echo $um->get_errors();
print_continue($returnurl);
$this->view_footer();
die;
}