本文整理汇总了PHP中ilObjFile::getUploadFile方法的典型用法代码示例。如果您正苦于以下问题:PHP ilObjFile::getUploadFile方法的具体用法?PHP ilObjFile::getUploadFile怎么用?PHP ilObjFile::getUploadFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ilObjFile
的用法示例。
在下文中一共展示了ilObjFile::getUploadFile方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: newFileItem
/**
* insert new file item
*/
function newFileItem()
{
global $lng;
if ($_FILES["file"]["name"] == "") {
$_GET["subCmd"] = "-";
ilUtil::sendFailure($lng->txt("upload_error_file_not_found"));
return false;
}
include_once "./Modules/File/classes/class.ilObjFile.php";
$fileObj = new ilObjFile();
$fileObj->setType("file");
$fileObj->setTitle($_FILES["file"]["name"]);
$fileObj->setDescription("");
$fileObj->setFileName($_FILES["file"]["name"]);
$fileObj->setFileType($_FILES["file"]["type"]);
$fileObj->setFileSize($_FILES["file"]["size"]);
$fileObj->setMode("filelist");
$fileObj->create();
$fileObj->raiseUploadError(false);
// upload file to filesystem
$fileObj->createDirectory();
$fileObj->getUploadFile($_FILES["file"]["tmp_name"], $_FILES["file"]["name"]);
$this->file_object =& $fileObj;
return true;
}
示例2: saveFileLink
/**
* Save file link
*/
function saveFileLink()
{
$mtpl =& new ilTemplate("tpl.link_help.html", true, true, "Modules/LearningModule");
$mtpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
if ($_FILES["link_file"]["name"] != "") {
include_once "./Modules/File/classes/class.ilObjFile.php";
$fileObj = new ilObjFile();
$fileObj->setType("file");
$fileObj->setTitle($_FILES["link_file"]["name"]);
$fileObj->setDescription("");
$fileObj->setFileName($_FILES["link_file"]["name"]);
$fileObj->setFileType($_FILES["link_file"]["type"]);
$fileObj->setFileSize($_FILES["link_file"]["size"]);
$fileObj->setMode("filelist");
$fileObj->create();
// upload file to filesystem
$fileObj->createDirectory();
$fileObj->raiseUploadError(false);
$fileObj->getUploadFile($_FILES["link_file"]["tmp_name"], $_FILES["link_file"]["name"]);
$this->uploaded_file = $fileObj;
}
$this->showLinkHelp();
}
示例3: generateFiles
/**
* Generate files
*
* @param
* @return
*/
function generateFiles($a_test_file, $a_files_per_course = 10, $a_title_base = "File")
{
global $tree;
include_once "./Modules/File/classes/class.ilObjFile.php";
$this->log("Creating Files");
$a_current = $a_start;
// get all categories and sort them by depth
$crs_ref_ids = ilUtil::_getObjectsByOperations("crs", "read", 0, $limit = 1000000);
$cnt = 1;
foreach ($crs_ref_ids as $rid) {
for ($i = 1; $i <= $a_files_per_course; $i++) {
$this->log($a_title_base . " " . $cnt);
$fileObj = new ilObjFile();
$fileObj->setTitle($a_title_base . " " . $cnt);
$fileObj->setFileName("file_" . $cnt . ".txt");
$fileObj->create();
$fileObj->createReference();
$fileObj->putInTree($rid);
$fileObj->setPermissions($rid);
$fileObj->createDirectory();
$fileObj->getUploadFile($a_test_file, "file_" . $cnt . ".txt");
$cnt++;
}
}
}
示例4: handleFileUpload
public function handleFileUpload()
{
global $tree;
include_once './Modules/Session/classes/class.ilEventItems.php';
$ev = new ilEventItems($this->object->getId());
$items = $ev->getItems();
$counter = 0;
while (true) {
if (!isset($_FILES['files']['name'][$counter])) {
break;
}
if (!strlen($_FILES['files']['name'][$counter])) {
$counter++;
continue;
}
include_once './Modules/File/classes/class.ilObjFile.php';
$file = new ilObjFile();
$file->setTitle(ilUtil::stripSlashes($_FILES['files']['name'][$counter]));
$file->setDescription('');
$file->setFileName(ilUtil::stripSlashes($_FILES['files']['name'][$counter]));
$file->setFileType($_FILES['files']['type'][$counter]);
$file->setFileSize($_FILES['files']['size'][$counter]);
$file->create();
$new_ref_id = $file->createReference();
$file->putInTree($tree->getParentId($this->object->getRefId()));
$file->setPermissions($tree->getParentId($this->object->getRefId()));
$file->createDirectory();
$file->getUploadFile($_FILES['files']['tmp_name'][$counter], $_FILES['files']['name'][$counter]);
$items[] = $new_ref_id;
$counter++;
}
$ev->setItems($items);
$ev->update();
}
示例5: parseValue
/**
* Function to parse incoming data from form input value $value. returns the strin/number/etc. to store in the database.
* @param $value
* @param ilDataCollectionRecordField $record_field
* @return int|string
*/
public function parseValue($value, ilDataCollectionRecordField $record_field)
{
$return = false;
if ($this->id == ilDataCollectionDatatype::INPUTFORMAT_FILE) {
$file = $value;
if ($file['tmp_name']) {
$file_obj = new ilObjFile();
$file_obj->setType("file");
$file_obj->setTitle($file["name"]);
$file_obj->setFileName($file["name"]);
$file_obj->setFileType(ilMimeTypeUtil::getMimeType("", $file["name"], $file["type"]));
$file_obj->setFileSize($file["size"]);
$file_obj->setMode("object");
$file_obj->create();
$file_obj->getUploadFile($file["tmp_name"], $file["name"]);
$file_id = $file_obj->getId();
$return = $file_id;
} else {
$return = $record_field->getValue();
}
} elseif ($this->id == ilDataCollectionDatatype::INPUTFORMAT_MOB) {
if ($value == -1) {
//marked for deletion.
return 0;
}
$media = $value;
if ($media['tmp_name']) {
$mob = new ilObjMediaObject();
$mob->setTitle($media['name']);
$mob->create();
$mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
if (!is_dir($mob_dir)) {
$mob->createDirectory();
}
$media_item = new ilMediaItem();
$mob->addMediaItem($media_item);
$media_item->setPurpose("Standard");
$file_name = ilUtil::getASCIIFilename($media['name']);
$file_name = str_replace(" ", "_", $file_name);
$file = $mob_dir . "/" . $file_name;
$title = $file_name;
ilUtil::moveUploadedFile($media['tmp_name'], $file_name, $file);
ilUtil::renameExecutables($mob_dir);
list($width, $height, $type, $attr) = getimagesize($file);
$arr_properties = $record_field->getField()->getProperties();
$new_width = $arr_properties[ilDataCollectionField::PROPERTYID_WIDTH];
$new_height = $arr_properties[ilDataCollectionField::PROPERTYID_HEIGHT];
if ($new_width || $new_height) {
//only resize if it is bigger, not if it is smaller
if ($new_height < $height && $new_width < $width) {
//resize proportional
if (!$new_height || !$new_width) {
$format = ilObjMediaObject::getMimeType($file);
$wh = ilObjMediaObject::_determineWidthHeight("", "", $format, "File", $file, "", true, false, $arr_properties[ilDataCollectionField::PROPERTYID_WIDTH], (int) $arr_properties[ilDataCollectionField::PROPERTYID_HEIGHT]);
} else {
$wh['width'] = (int) $arr_properties[ilDataCollectionField::PROPERTYID_WIDTH];
$wh['height'] = (int) $arr_properties[ilDataCollectionField::PROPERTYID_HEIGHT];
}
}
$location = ilObjMediaObject::_resizeImage($file, $wh['width'], $wh['height'], false);
} else {
$location = $title;
}
ilObjMediaObject::_saveUsage($mob->getId(), "dcl:html", $record_field->getRecord()->getTable()->getCollectionObject()->getId());
$format = ilObjMediaObject::getMimeType($file);
$media_item->setFormat($format);
$media_item->setLocation($location);
$media_item->setLocationType("LocalFile");
$mob->update();
$return = $mob->getId();
} else {
$return = $record_field->getValue();
}
} elseif ($this->id == ilDataCollectionDatatype::INPUTFORMAT_DATETIME) {
return $value["date"] . " " . $value["time"];
} elseif ($this->id == ilDataCollectionDatatype::INPUTFORMAT_BOOLEAN) {
$return = $value ? 1 : 0;
} elseif ($this->id == ilDataCollectionDatatype::INPUTFORMAT_TEXT) {
$arr_properties = $record_field->getField()->getProperties();
if ($arr_properties[ilDataCollectionField::PROPERTYID_TEXTAREA]) {
$return = nl2br($value);
} else {
$return = $value;
}
} else {
if ($this->id == ilDataCollectionDatatype::INPUTFORMAT_NUMBER) {
$return = $value == '' ? null : $value;
//SW, Ilias Mantis #0011799: Return null otherwise '' is casted to 0 in DB
} else {
$return = $value;
}
}
return $return;
}