本文整理匯總了PHP中field::getFileSize方法的典型用法代碼示例。如果您正苦於以下問題:PHP field::getFileSize方法的具體用法?PHP field::getFileSize怎麽用?PHP field::getFileSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類field
的用法示例。
在下文中一共展示了field::getFileSize方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: uploadFile
private function uploadFile()
{
//--Check if the file is an image or file
if ($this->isImage()) {
// the image path
$path = FRONTEND_FILES_PATH . '/Media/Images';
if (!\SpoonDirectory::exists($path . '/Source')) {
\SpoonDirectory::create($path . '/Source');
}
} else {
// the file path
$path = FRONTEND_FILES_PATH . '/Media/Files';
}
// create folders if needed
// build the filename
$filename = $this->checkFilename();
$item = array();
$item["filename"] = $filename;
$item["extension"] = $this->field->getExtension();
$item["created_on"] = BackendModel::getUTCDate('Y-m-d H:i:s');
$item["filesize"] = $this->field->getFileSize("b");
$data = array();
//--Check if file is an image to specify data
if ($this->isImage()) {
$item["filetype"] = $this->fieldTypeImage;
//--Put file on disk
$this->field->moveFile($path . "/Source/" . $filename);
// create folders if needed
if (!\SpoonDirectory::exists($path . '/128x128')) {
\SpoonDirectory::create($path . '/128x128');
}
//--Create all tumbs/resizes of file
$thumbnail = new \SpoonThumbnail($path . "/Source/" . $filename);
$thumbnail->setAllowEnlargement(true);
\Common\Core\Model::generateThumbnails($path, $path . '/Source/' . $filename);
} else {
$item["filetype"] = $this->fieldTypeFile;
// move the source file
$this->field->moveFile($path . "/" . $filename);
}
//--Serialize data
$item["data"] = serialize($data);
//--Store item so we can access it
$this->item = $item;
//--Insert into media
return BackendModel::getContainer()->get('database')->insert("media", $item);
}