本文整理汇总了PHP中Uploader::setCheckFileSize方法的典型用法代码示例。如果您正苦于以下问题:PHP Uploader::setCheckFileSize方法的具体用法?PHP Uploader::setCheckFileSize怎么用?PHP Uploader::setCheckFileSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Uploader
的用法示例。
在下文中一共展示了Uploader::setCheckFileSize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processImportTheme
public function processImportTheme()
{
$this->display = 'importtheme';
if ($this->context->mode == Context::MODE_HOST) {
return true;
}
if (isset($_FILES['themearchive']) && isset($_POST['filename']) && Tools::isSubmit('theme_archive_server')) {
$uniqid = uniqid();
$sandbox = _PS_CACHE_DIR_ . 'sandbox' . DIRECTORY_SEPARATOR . $uniqid . DIRECTORY_SEPARATOR;
mkdir($sandbox);
$archive_uploaded = false;
if (Tools::getValue('filename') != '') {
$uploader = new Uploader('themearchive');
$uploader->setCheckFileSize(false);
$uploader->setAcceptTypes(array('zip'));
$uploader->setSavePath($sandbox);
$file = $uploader->process(Theme::UPLOADED_THEME_DIR_NAME . '.zip');
if ($file[0]['error'] === 0) {
if (Tools::ZipTest($sandbox . Theme::UPLOADED_THEME_DIR_NAME . '.zip')) {
$archive_uploaded = true;
} else {
$this->errors[] = $this->l('Zip file seems to be broken');
}
} else {
$this->errors[] = $file[0]['error'];
}
} elseif (Tools::getValue('themearchiveUrl') != '') {
if (!Validate::isModuleUrl($url = Tools::getValue('themearchiveUrl'), $this->errors)) {
$this->errors[] = $this->l('Only zip files are allowed');
} elseif (!Tools::copy($url, $sandbox . Theme::UPLOADED_THEME_DIR_NAME . '.zip')) {
$this->errors[] = $this->l('Error during the file download');
} elseif (Tools::ZipTest($sandbox . Theme::UPLOADED_THEME_DIR_NAME . '.zip')) {
$archive_uploaded = true;
} else {
$this->errors[] = $this->l('Zip file seems to be broken');
}
} elseif (Tools::getValue('theme_archive_server') != '') {
$filename = _PS_ALL_THEMES_DIR_ . Tools::getValue('theme_archive_server');
if (substr($filename, -4) != '.zip') {
$this->errors[] = $this->l('Only zip files are allowed');
} elseif (!copy($filename, $sandbox . Theme::UPLOADED_THEME_DIR_NAME . '.zip')) {
$this->errors[] = $this->l('An error has occurred during the file copy.');
} elseif (Tools::ZipTest($sandbox . Theme::UPLOADED_THEME_DIR_NAME . '.zip')) {
$archive_uploaded = true;
} else {
$this->errors[] = $this->l('Zip file seems to be broken');
}
} else {
$this->errors[] = $this->l('You must upload or enter a location of your zip');
}
if ($archive_uploaded) {
if ($this->extractTheme($sandbox . Theme::UPLOADED_THEME_DIR_NAME . '.zip', $sandbox)) {
$this->installTheme(Theme::UPLOADED_THEME_DIR_NAME, $sandbox);
}
}
Tools::deleteDirectory($sandbox);
if (count($this->errors) > 0) {
$this->display = 'importtheme';
} else {
Tools::redirectAdmin(Context::getContext()->link->getAdminLink('AdminThemes') . '&conf=18');
}
}
}