本文整理汇总了PHP中ilUtil::moveUploadedFile方法的典型用法代码示例。如果您正苦于以下问题:PHP ilUtil::moveUploadedFile方法的具体用法?PHP ilUtil::moveUploadedFile怎么用?PHP ilUtil::moveUploadedFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ilUtil
的用法示例。
在下文中一共展示了ilUtil::moveUploadedFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: uploadFile
/**
* Saves file, fetched from $_FILES to specified upload path.
*
* @global ilObjUser $ilUser
*/
public function uploadFile()
{
global $ilCtrl;
if (!ilChatroom::checkUserPermissions('read', $this->gui->ref_id)) {
$ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", ROOT_FOLDER_ID);
$ilCtrl->redirectByClass("ilrepositorygui", "");
}
$upload_path = $this->getUploadPath();
$this->checkUploadPath($upload_path);
/**
* @todo: filename must be unique.
*/
$file = $_FILES['file_to_upload']['tmp_name'];
$filename = $_FILES['file_to_upload']['name'];
$type = $_FILES['file_to_upload']['type'];
$target = $upload_path . $filename;
if (ilUtil::moveUploadedFile($file, $filename, $target)) {
global $ilUser;
require_once 'Modules/Chatroom/classes/class.ilChatroom.php';
require_once 'Modules/Chatroom/classes/class.ilChatroomUser.php';
$room = ilChatroom::byObjectId($this->gui->object->getId());
$chat_user = new ilChatroomUser($ilUser, $room);
$user_id = $chat_user->getUserId();
if (!$room) {
throw new Exception('unkown room');
} else {
if (!$room->isSubscribed($chat_user->getUserId())) {
throw new Exception('not subscribed');
}
}
$room->saveFileUploadToDb($user_id, $filename, $type);
$this->displayLinkToUploadedFile($room, $chat_user);
}
}
示例2: storeUploadedFile
public function storeUploadedFile($a_http_post_file)
{
if ($this->image_current != '') {
$this->unlinkFile($this->image_current);
}
if (isset($a_http_post_file) && $a_http_post_file['size']) {
if (ilUtil::moveUploadedFile($a_http_post_file['tmp_name'], $a_http_post_file['name'], $this->shop_path . '/' . $a_http_post_file['name'])) {
ilUtil::resizeImage('"' . $this->shop_path . '/' . $a_http_post_file['name'] . '"', '"' . $this->shop_path . '/' . $a_http_post_file['name'] . '"', 100, 75);
return $this->image_new = $a_http_post_file['name'];
}
}
return false;
}
示例3: importBookingsFromDaVinciFile
/**
* Imports rooms and bookings from a given daVinci file
*
* @param type $file daVinci text file from file upload form
* @param boolean $import_rooms true to import rooms
* @param boolean $import_bookings true to import bookings
* @param int $default_cap sets the default room capacity
*/
public function importBookingsFromDaVinciFile($file, $import_rooms, $import_bookings, $default_cap)
{
$this->count_Bookings_without_Room = 0;
$this->count_Rooms_created = 0;
$this->count_Bookings_created = 0;
$file_name = ilUtil::getASCIIFilename($file["name"]);
$file_name_mod = str_replace(" ", "_", $file_name);
$file_path = "templates" . "/" . $file_name_mod;
// construct file path
ilUtil::moveUploadedFile($file["tmp_name"], $file_name_mod, $file_path);
$fileAsString = file_get_contents($file_path);
ilUtil::sendInfo($this->lng->txt("rep_robj_xrs_daVinci_import_message_start"), true);
foreach (preg_split("/((\r?\n)|(\r\n?))/", $fileAsString) as $line) {
$this->checkForKey($line);
}
ilUtil::sendInfo($this->createInfoMessage($import_rooms, $import_bookings), true);
if ($import_rooms === "1") {
foreach ($this->rooms as $room) {
if (!($this->ilRoomSharingDatabase->getRoomWithName($room['name']) !== array())) {
if ($room['cap'] == 0) {
$room['cap'] = (int) $default_cap;
}
//$a_name, $a_type, $a_min_alloc, $a_max_alloc, $a_file_id, $a_building_id
$this->ilRoomSharingDatabase->insertRoom($room['name'], $room['type'], 1, $room['cap'], array(), array());
$this->count_Rooms_created++;
}
}
}
if ($import_bookings === "1") {
foreach ($this->appointments as $booking) {
if ($booking['day'] != 0) {
$usedWeek = clone $this->startingDate;
for ($i = 0; $i < strlen($this->activeWeeks); $i++) {
if ($booking['week'] != NULL) {
if ($booking['week'][$i] === 'X') {
$this->addDaVinciBooking($booking['day'], $booking['start'], $booking['end'], $booking['room'], $booking['prof'], $booking['subject'], $booking['classes'], $usedWeek);
}
} else {
if ($this->activeWeeks[$i] === 'X') {
$this->addDaVinciBooking($booking['day'], $booking['start'], $booking['end'], $booking['room'], $booking['prof'], $booking['subject'], $booking['classes'], $usedWeek);
}
}
$usedWeek->add(new DateInterval('P7D'));
}
}
}
}
$this->displayInfo();
}
示例4: generate
/**
* Generate the report for given certificate
*
* @param srCertificate $cert
* @throws ilException
* @return bool
*/
public function generate(srCertificate $cert)
{
if (!$this->isAvailable()) {
throw new ilException("Generating certificates with TemplateTypeJasper is only available if the JasperReport service is installed");
}
require_once self::JASPER_CLASS;
$template = $cert->getDefinition()->getType()->getCertificateTemplatesPath(true);
// A template is required, so quit early if it does not exist for some reason
if (!is_file($template)) {
return false;
}
$placeholders = $cert->getPlaceholders();
try {
$defined_placeholders = $this->parseDefinedPlaceholders($template);
} catch (Exception $e) {
// XML is not valid
return false;
}
// Only send defined placeholders to jasper, otherwise the template file is not considered as valid
$placeholders = array_intersect_key($placeholders, $defined_placeholders);
$placeholders = $this->nl2br($placeholders);
$report = new JasperReport($template, $cert->getFilename(false));
if ($locale = $this->pl->config('jasper_locale')) {
$report->setLocale($this->pl->config('jasper_locale'));
}
if ($java = $this->pl->config('jasper_path_java')) {
$report->setPathJava($java);
}
$report->setDataSource(JasperReport::DATASOURCE_EMPTY);
$report->setParameters($placeholders);
try {
$report->generateOutput();
$report_file = $report->getOutputFile();
// Move pdf to correct certificate location
$cert_path = $cert->getCertificatePath();
if (!file_exists($cert_path)) {
ilUtil::makeDirParents($cert_path);
}
$from = $report_file . '.pdf';
$to = $cert->getFilePath();
return ilUtil::moveUploadedFile($from, '', $to, false, 'rename');
} catch (JasperReportException $e) {
$this->log->write("srCertificateTemplyteTypeJasper::generate() Report file of certificate with ID {$cert->getId()} was not created by Jasper: " . implode(', ', $e->getErrors()));
return false;
}
}
示例5: storeUploadedFile
/**
* store uploaded file in filesystem
* @param array HTTP_POST_FILES
* @access public
* @return bool
*/
function storeUploadedFile($a_http_post_file)
{
// TODO:
// CHECK UPLOAD LIMIT
//
if (isset($a_http_post_file) && $a_http_post_file['size']) {
// DELETE OLD FILES
$this->unlinkLast();
// CHECK IF FILE WITH SAME NAME EXISTS
ilUtil::moveUploadedFile($a_http_post_file['tmp_name'], $a_http_post_file['name'], $this->getPath() . '/' . $a_http_post_file['name']);
//move_uploaded_file($a_http_post_file['tmp_name'],$this->getPath().'/'.$a_http_post_file['name']);
// UPDATE FILES LIST
$this->__readFiles();
return true;
} else {
return false;
}
}
示例6: uploadAppointments
/**
* Upload appointments
*/
protected function uploadAppointments()
{
// @todo permission check
$form = $this->initImportForm();
if ($form->checkInput()) {
$file = $form->getInput('file');
$tmp = ilUtil::ilTempnam();
ilUtil::moveUploadedFile($file['tmp_name'], $file['name'], $tmp);
$num = $this->doImportFile($tmp, (int) $_REQUEST['category_id']);
ilUtil::sendSuccess(sprintf($this->lng->txt('cal_imported_success'), (int) $num), true);
$this->ctrl->redirect($this, 'manage');
}
ilUtil::sendFailure($this->lng->txt('cal_err_file_upload'), true);
$this->initImportForm($form);
}
示例7: setJavaAppletFilename
/**
* Sets the java applet file name
*
* @param string $javaapplet_file.
* @access public
* @see $javaapplet_filename
*/
function setJavaAppletFilename($javaapplet_filename, $javaapplet_tempfilename = "")
{
if (!empty($javaapplet_filename)) {
$this->javaapplet_filename = $javaapplet_filename;
}
if (!empty($javaapplet_tempfilename)) {
$javapath = $this->getJavaPath();
if (!file_exists($javapath)) {
ilUtil::makeDirParents($javapath);
}
if (!ilUtil::moveUploadedFile($javaapplet_tempfilename, $javaapplet_filename, $javapath . $javaapplet_filename)) {
$ilLog->write("ERROR: java applet question: java applet not uploaded: {$javaapplet_filename}");
} else {
$this->setJavaCodebase();
$this->setJavaArchive();
}
}
}
示例8: importObject
/**
* Import repository object export file
*
* @param string absolute filename of temporary upload file
*/
public final function importObject($a_new_obj, $a_tmp_file, $a_filename, $a_type, $a_comp = "", $a_copy_file = false)
{
// create temporary directory
$tmpdir = ilUtil::ilTempnam();
ilUtil::makeDir($tmpdir);
if ($a_copy_file) {
copy($a_tmp_file, $tmpdir . "/" . $a_filename);
} else {
ilUtil::moveUploadedFile($a_tmp_file, $a_filename, $tmpdir . "/" . $a_filename);
}
ilUtil::unzip($tmpdir . "/" . $a_filename);
$dir = $tmpdir . "/" . substr($a_filename, 0, strlen($a_filename) - 4);
$GLOBALS['ilLog']->write(__METHOD__ . ': do import with dir ' . $dir);
$new_id = $this->doImportObject($dir, $a_type, $a_comp, $tmpdir);
// delete temporary directory
ilUtil::delDir($tmpdir);
return $new_id;
}
示例9: import
/**
* Import
*/
function import($a_file)
{
parent::create();
$im_dir = $this->createImportDirectory();
// handle uploaded files
if (is_array($a_file)) {
ilUtil::moveUploadedFile($a_file["tmp_name"], $a_file["name"], $im_dir . "/" . $a_file["name"]);
$file_name = $a_file["name"];
} else {
$pi = pathinfo($a_file);
$file_name = $pi["basename"];
copy($a_file, $im_dir . "/" . $file_name);
}
$file = pathinfo($file_name);
// unzip file
if (strtolower($file["extension"] == "zip")) {
ilUtil::unzip($im_dir . "/" . $file_name);
$subdir = basename($file["basename"], "." . $file["extension"]);
if (!is_dir($im_dir . "/" . $subdir)) {
$subdir = "style";
// check style subdir
}
$xml_file = $im_dir . "/" . $subdir . "/style.xml";
} else {
$xml_file = $im_dir . "/" . $file_name;
}
// load information from xml file
//echo "-$xml_file-";
$this->createFromXMLFile($xml_file, true);
// copy images
$this->createImagesDirectory();
if (is_dir($im_dir . "/" . $subdir . "/images")) {
ilUtil::rCopy($im_dir . "/" . $subdir . "/images", $this->getImagesDirectory());
}
ilObjStyleSheet::_addMissingStyleClassesToStyle($this->getId());
$this->read();
$this->writeCSSFile();
}
示例10: updateMediaItem
/**
* update media item from form
*
* @param IlObjectMediaObject $mob
* @param IlMediaItem $mediaItem
* @return string file
*/
private function updateMediaItem($mob, &$mediaItem)
{
$purpose = $mediaItem->getPurpose();
$url_gui = $this->form_gui->getInput("url_" . $purpose);
$file_gui = $this->form_gui->getInput("file_" . $purpose);
if ($url_gui) {
// http
$file = $this->form_gui->getInput("url_" . $purpose);
$title = basename($file);
$location = $this->form_gui->getInput("url_" . $purpose);
$locationType = "Reference";
} elseif ($file_gui["size"] > 0) {
// lokal
// determine and create mob directory, move uploaded file to directory
$mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
if (!is_dir($mob_dir)) {
$mob->createDirectory();
}
$file_name = ilUtil::getASCIIFilename($_FILES['file_' . $purpose]['name']);
$file_name = str_replace(" ", "_", $file_name);
$file = $mob_dir . "/" . $file_name;
$title = $file_name;
$locationType = "LocalFile";
$location = $title;
ilUtil::moveUploadedFile($_FILES['file_' . $purpose]['tmp_name'], $file_name, $file);
ilUtil::renameExecutables($mob_dir);
}
// check if not automatic mimetype detection
if ($_POST["mimetype_" . $purpose] != "") {
$mediaItem->setFormat($_POST["mimetype_" . $purpose]);
} elseif ($mediaItem->getLocation() != "") {
$format = ilObjMediaObject::getMimeType($mediaItem->getLocation());
$mediaItem->setFormat($format);
}
if (isset($file)) {
// get mime type, if not already set!
if (!isset($format)) {
$format = ilObjMediaObject::getMimeType($file);
}
// set real meta and object data
$mediaItem->setFormat($format);
$mediaItem->setLocation($location);
$mediaItem->setLocationType($locationType);
$mediaItem->setHAlign("Left");
$mediaItem->setHeight(self::isAudio($format) ? 0 : 180);
}
if ($purpose == "Standard") {
if (isset($title)) {
$mob->setTitle($title);
}
if (isset($format)) {
$mob->setDescription($format);
}
}
return $file;
}
示例11: importFileObject
/**
* form for new survey object import
*/
public function importFileObject()
{
global $tpl, $ilErr;
$parent_id = $_GET["ref_id"];
$new_type = $_REQUEST["new_type"];
// create permission is already checked in createObject. This check here is done to prevent hacking attempts
if (!$this->checkPermissionBool("create", "", $new_type)) {
$ilErr->raiseError($this->lng->txt("no_create_permission"));
}
$this->lng->loadLanguageModule($new_type);
$this->ctrl->setParameter($this, "new_type", $new_type);
$form = $this->initImportForm($new_type);
if ($form->checkInput()) {
include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
$newObj = new ilObjSurveyQuestionPool();
$newObj->setType($new_type);
$newObj->setTitle("dummy");
$newObj->create(true);
$this->putObjectInTree($newObj);
$newObj->createImportDirectory();
// copy uploaded file to import directory
$upload = $_FILES["importfile"];
$file = pathinfo($upload["name"]);
$full_path = $newObj->getImportDirectory() . "/" . $upload["name"];
include_once "./Services/Utilities/classes/class.ilUtil.php";
ilUtil::moveUploadedFile($upload["tmp_name"], $upload["name"], $full_path);
// import qti data
$qtiresult = $newObj->importObject($full_path);
ilUtil::sendSuccess($this->lng->txt("object_imported"), true);
ilUtil::redirect("ilias.php?ref_id=" . $newObj->getRefId() . "&baseClass=ilObjSurveyQuestionPoolGUI");
}
// display form to correct errors
$form->setValuesByPost();
$tpl->setContent($form->getHtml());
}
示例12: updateSocialBookmarkObject
function updateSocialBookmarkObject()
{
global $ilAccess, $rbacreview, $lng, $ilCtrl;
if (!$ilAccess->checkAccess("write", "", $this->object->getRefId())) {
$this->ilias->raiseError($this->lng->txt("permission_denied"), $this->ilias->error_obj->MESSAGE);
}
include_once './Services/Administration/classes/class.ilSocialBookmarks.php';
$form = ilSocialBookmarks::_initForm($this, 'update');
if ($form->checkInput()) {
$title = $form->getInput('title');
$link = $form->getInput('link');
$file = $form->getInput('image_file');
$active = $form->getInput('activate');
$id = $form->getInput('sbm_id');
if (!$file['name']) {
ilSocialBookmarks::_updateSocialBookmark($id, $title, $link, $active);
} else {
$extension = pathinfo($file['name'], PATHINFO_EXTENSION);
$icon_path = ilUtil::getWebspaceDir() . DIRECTORY_SEPARATOR . 'social_bm_icons' . DIRECTORY_SEPARATOR . time() . '.' . $extension;
$path = ilUtil::getWebspaceDir() . DIRECTORY_SEPARATOR . 'social_bm_icons';
if (!is_dir($path)) {
ilUtil::createDirectory($path);
}
ilSocialBookmarks::_deleteImage($id);
ilSocialBookmarks::_updateSocialBookmark($id, $title, $link, $active, $icon_path);
ilUtil::moveUploadedFile($file['tmp_name'], $file['name'], $icon_path);
}
$this->editSocialBookmarksObject();
} else {
$this->__initSubTabs("editSocialBookmarks");
$form->setValuesByPost();
$this->tpl->setVariable('ADM_CONTENT', $form->getHTML());
}
}
示例13: uploadRoomsAgreement
/**
* Uploads a new rooms agreement by using the ILIAS MediaObject Service.
* If the old file id is given, the old file will be deleted.
*
* @param array $a_newfile an array containing the input values of the form
* @param string $a_oldFileId to delete trash
*
* @return string uploaded file id
*/
public function uploadRoomsAgreement($a_newfile, $a_oldFileId = "0")
{
if (!empty($a_oldFileId) && $a_oldFileId != "0") {
$agreementFile = new ilObjMediaObject($a_oldFileId);
$agreementFile->delete();
}
$mediaObj = new ilObjMediaObject();
$mediaObj->setTitle("RoomSharingRoomsAgreement");
$mediaObj->setDescription("RoomSharingRoomsAgreement");
$mediaObj->create();
$mob_dir = ilObjMediaObject::_getDirectory($mediaObj->getId());
if (!is_dir($mob_dir)) {
$mediaObj->createDirectory();
}
$file_name = ilUtil::getASCIIFilename($a_newfile["name"]);
$file_name_mod = str_replace(" ", "_", $file_name);
$file = $mob_dir . "/" . $file_name_mod;
ilUtil::moveUploadedFile($a_newfile["tmp_name"], $file_name_mod, $file);
ilUtil::renameExecutables($mob_dir);
$format = ilObjMediaObject::getMimeType($file);
$media_item = new ilMediaItem();
$mediaObj->addMediaItem($media_item);
$media_item->setPurpose("Standard");
$media_item->setFormat($format);
$media_item->setLocation($file_name_mod);
$media_item->setLocationType("LocalFile");
$mediaObj->update();
return $mediaObj->getId();
}
示例14: importFromZipFile
/**
* Import lm from zip file
*
* @param
* @return
*/
function importFromZipFile($a_tmp_file, $a_filename, $a_validate = true, $a_import_into_help_module = 0)
{
global $lng;
// create import directory
$this->createImportDirectory();
// copy uploaded file to import directory
$file = pathinfo($a_filename);
$full_path = $this->getImportDirectory() . "/" . $a_filename;
ilUtil::moveUploadedFile($a_tmp_file, $a_filename, $full_path);
// unzip file
ilUtil::unzip($full_path);
$subdir = basename($file["basename"], "." . $file["extension"]);
$mess = $this->importFromDirectory($this->getImportDirectory() . "/" . $subdir, $a_validate);
// this should only be true for help modules
if ($a_import_into_help_module > 0) {
// search the zip file
$dir = $this->getImportDirectory() . "/" . $subdir;
$files = ilUtil::getDir($dir);
foreach ($files as $file) {
if (is_int(strpos($file["entry"], "__help_")) && is_int(strpos($file["entry"], ".zip"))) {
include_once "./Services/Export/classes/class.ilImport.php";
$imp = new ilImport();
$imp->getMapping()->addMapping('Services/Help', 'help_module', 0, $a_import_into_help_module);
include_once "./Modules/LearningModule/classes/class.ilLMObject.php";
$chaps = ilLMObject::getObjectList($this->getId(), "st");
foreach ($chaps as $chap) {
$chap_arr = explode("_", $chap["import_id"]);
$imp->getMapping()->addMapping('Services/Help', 'help_chap', $chap_arr[count($chap_arr) - 1], $chap["obj_id"]);
}
$imp->importEntity($dir . "/" . $file["entry"], $file["entry"], "help", "Services/Help", true);
}
}
}
// delete import directory
ilUtil::delDir($this->getImportDirectory());
return $mess;
}
示例15: setImageFile
/**
* Sets the image file and uploads the image to the object's image directory.
*
* @param string $image_filename Name of the original image file
* @param string $image_tempfilename Name of the temporary uploaded image file
* @return integer An errorcode if the image upload fails, 0 otherwise
* @access public
*/
function setImageFile($image_tempfilename, $image_filename, $previous_filename)
{
$result = TRUE;
if (strlen($image_tempfilename)) {
$image_filename = str_replace(" ", "_", $image_filename);
$imagepath = $this->getImagePath();
if (!file_exists($imagepath)) {
ilUtil::makeDirParents($imagepath);
}
$savename = $image_filename;
if (!ilUtil::moveUploadedFile($image_tempfilename, $savename, $imagepath . $savename)) {
$result = FALSE;
} else {
// create thumbnail file
$thumbpath = $imagepath . $this->getThumbPrefix() . $savename;
ilUtil::convertImage($imagepath . $savename, $thumbpath, "JPEG", $this->getThumbGeometry());
}
if ($result && strcmp($image_filename, $previous_filename) != 0 && strlen($previous_filename)) {
$this->deleteImagefile($previous_filename);
}
}
return $result;
}