当前位置: 首页>>代码示例>>PHP>>正文


PHP Uploader::setCheckFileSize方法代码示例

本文整理汇总了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');
         }
     }
 }
开发者ID:zangles,项目名称:lennyba,代码行数:63,代码来源:AdminThemesController.php


注:本文中的Uploader::setCheckFileSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。