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


PHP uploader::canUpload方法代码示例

本文整理汇总了PHP中uploader::canUpload方法的典型用法代码示例。如果您正苦于以下问题:PHP uploader::canUpload方法的具体用法?PHP uploader::canUpload怎么用?PHP uploader::canUpload使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在uploader的用法示例。


在下文中一共展示了uploader::canUpload方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _processIndUpload

 /**
  *
  */
 function _processIndUpload(&$oUploader, $myFileName, $tmpFile, $arrayInc, $myFileDir = '', $file)
 {
     $params = $this->getParams();
     if ($params->get('ul_file_types') == '') {
         $params->set('ul_file_types', implode(',', $this->_aDefaultFileTypes));
     }
     $folder = $params->get('ul_directory');
     if ($myFileDir != '') {
         $folder .= JPath::clean(JPATH_SITE . '/' . $myFileDir);
     }
     $oUploader->_makeRecursiveFolders($folder);
     $folder = JPath::clean(JPATH_SITE . '/' . $folder);
     $err = null;
     // Set FTP credentials, if given
     jimport('joomla.client.helper');
     JClientHelper::setCredentialsFromRequest('ftp');
     if ($myFileName != '') {
         $filepath = JPath::clean($folder . '/' . JString::strtolower($myFileName));
         if (!uploader::canUpload($file, $err, $params)) {
             return JError::raiseNotice(100, JText::_($err));
         }
         if (JFile::exists($filepath)) {
             if ($params->get('ul_file_increment', 0)) {
                 $filepath = uploader::incrementFileName($filepath, $filepath, 1);
             } else {
                 return JError::raiseNotice(100, JText::_('A file of that name already exists'));
             }
         }
         if (!JFile::upload($tmpFile, $filepath)) {
             $oUploader->moveError = true;
             JError::raiseWarning(100, JText::_("Error. Unable to upload file (from {$tmpFile} to {$destFile})"));
         } else {
             jimport('joomla.filesystem.path');
             JPath::setPermissions($destFile);
             //resize main image
             $oImage = FabimageHelper::loadLib($params->get('image_library'));
             $mainWidth = $params->get('fu_main_max_width');
             $mainHeight = $params->get('fu_main_max_height');
             if ($params->get('make_thumbnail') == '1') {
                 $thumbPath = JPath::clean($params->get('thumb_dir') . '/' . $myFileDir . '/');
                 $thumbPrefix = $params->get('thumb_prefix');
                 $maxWidth = $params->get('thumb_max_width');
                 $maxHeight = $params->get('thumb_max_height');
                 if ($thumbPath != '') {
                     $oUploader->_makeRecursiveFolders($thumbPath);
                 }
                 $destThumbFile = JPath::clean(JPATH_SITE . '/' . $thumbPath . '/' . $thumbPrefix . basename($filepath));
                 $msg = $oImage->resize($maxWidth, $maxHeight, $filepath, $destThumbFile);
             }
             if ($mainWidth != '' || $mainHeight != '') {
                 $msg = $oImage->resize($mainWidth, $mainHeight, $filepath, $filepath);
             }
             $res = str_replace(JPATH_SITE, '', $filepath);
             return $res;
         }
     }
 }
开发者ID:rogeriocc,项目名称:fabrik,代码行数:60,代码来源:video.php

示例2: _processIndUpload

 /**
  * process the upload (can be called via ajax from pluploader
  * @access private
  *
  * @param array $file info
  * @param string user selected upload folder
  * @param int repeat group counter
  * @return string location of uploaded file
  */
 protected function _processIndUpload(&$file, $myFileDir = '', $repeatGroupCounter = 0)
 {
     $params = $this->getParams();
     $storage = $this->getStorage();
     // $$$ hugh - check if we need to blow away the cached filepath, set in validation
     $myFileName = $storage->cleanName($file['name'], $repeatGroupCounter);
     if ($myFileName != $file['name']) {
         $file['name'] = $myFileName;
         unset($this->_filePaths[$repeatGroupCounter]);
     }
     $tmpFile = $file['tmp_name'];
     $uploader = $this->getFormModel()->getUploader();
     if ($params->get('ul_file_types') == '') {
         $params->set('ul_file_types', implode(',', $this->_getAllowedExtension()));
     }
     $err = null;
     // Set FTP credentials, if given
     jimport('joomla.client.helper');
     JClientHelper::setCredentialsFromRequest('ftp');
     if ($myFileName == '') {
         return;
     }
     $filepath = $this->_getFilePath($repeatGroupCounter);
     if (!uploader::canUpload($file, $err, $params)) {
         $this->setError(100, $file['name'] . ': ' . JText::_($err));
     }
     if ($storage->exists($filepath)) {
         switch ($params->get('ul_file_increment', 0)) {
             case 0:
                 break;
             case 1:
                 $filepath = uploader::incrementFileName($filepath, $filepath, 1);
                 break;
             case 2:
                 $storage->delete($filepath);
                 break;
         }
     }
     if (!$storage->upload($tmpFile, $filepath)) {
         $uploader->moveError = true;
         $this->setError(100, JText::sprintf('PLG_ELEMENT_FILEUPLOAD_UPLOAD_ERR', $tmpFile, $filepath));
         return;
     }
     $filepath = $storage->getUploadedFilePath();
     jimport('joomla.filesystem.path');
     $storage->setPermissions($filepath);
     // $$$ hugh @TODO - shouldn't we check to see if it's actually an image before we do any of this stuff???
     //resize main image
     $oImage = FabimageHelper::loadLib($params->get('image_library'));
     $oImage->setStorage($storage);
     // $$$ hugh - removing default of 200, otherwise we ALWAYS resize, whereas
     // tooltip on these options say 'leave blank for no resizing'
     $mainWidth = $params->get('fu_main_max_width', '');
     $mainHeight = $params->get('fu_main_max_height', '');
     if ($mainWidth != '' || $mainHeight != '') {
         // $$$ rob ensure that both values are integers otherwise resize fails
         if ($mainHeight == '') {
             $mainHeight = (int) $mainWidth;
         }
         if ($mainWidth == '') {
             $mainWidth = (int) $mainHeight;
         }
         $oImage->resize($mainWidth, $mainHeight, $filepath, $filepath);
     }
     // $$$ hugh - if it's a PDF, make sure option is set to attempt PDF thumb
     $make_thumbnail = $params->get('make_thumbnail') == '1' ? true : false;
     if (JFile::getExt($filepath) == 'pdf' && $params->get('fu_make_pdf_thumb', '0') == '0') {
         $make_thumbnail = false;
     }
     if ($make_thumbnail) {
         $thumbPath = $storage->clean(JPATH_SITE . '/' . $params->get('thumb_dir') . '/' . $myFileDir . '/', false);
         $w = new FabrikWorker();
         $thumbPath = $w->parseMessageForPlaceHolder($thumbPath);
         $thumbPrefix = $params->get('thumb_prefix');
         $maxWidth = $params->get('thumb_max_width', 125);
         $maxHeight = $params->get('thumb_max_height', 125);
         if ($thumbPath != '') {
             if (!$storage->folderExists($thumbPath)) {
                 if (!$storage->createFolder($thumbPath)) {
                     JError::raiseError(21, "Could not make dir {$thumbPath} ");
                 }
             }
         }
         $fileURL = $storage->getFileUrl(str_replace(COM_FABRIK_BASE, '', $filepath));
         $destThumbFile = $storage->_getThumb($fileURL);
         $destThumbFile = $storage->urlToPath($destThumbFile);
         $oImage->resize($maxWidth, $maxHeight, $filepath, $destThumbFile);
         $storage->setPermissions($destThumbFile);
     }
     $storage->setPermissions($filepath);
     $storage->finalFilePathParse($filepath);
//.........这里部分代码省略.........
开发者ID:romuland,项目名称:khparts,代码行数:101,代码来源:fileupload.php


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