本文整理汇总了PHP中field::moveFile方法的典型用法代码示例。如果您正苦于以下问题:PHP field::moveFile方法的具体用法?PHP field::moveFile怎么用?PHP field::moveFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类field
的用法示例。
在下文中一共展示了field::moveFile方法的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);
}