本文整理汇总了PHP中qqFileUploader::getFileExtension方法的典型用法代码示例。如果您正苦于以下问题:PHP qqFileUploader::getFileExtension方法的具体用法?PHP qqFileUploader::getFileExtension怎么用?PHP qqFileUploader::getFileExtension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qqFileUploader
的用法示例。
在下文中一共展示了qqFileUploader::getFileExtension方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: convertStringToArray
$phpwcms['file_maxsize'] = $upload_max_filesize - 1;
}
} else {
$upload_max_filesize = $phpwcms['file_maxsize'];
}
if (is_string($phpwcms['allowed_upload_ext'])) {
$phpwcms['allowed_upload_ext'] = convertStringToArray(strtolower($phpwcms['allowed_upload_ext']));
}
$uploader = new qqFileUploader($phpwcms['allowed_upload_ext'], min($post_max_size, $upload_max_filesize, $phpwcms['file_maxsize']));
$uploadDir = PHPWCMS_ROOT . $phpwcms["ftp_path"];
// Call handleUpload() with the name of the folder, relative to PHP's getcwd()
$result = $uploader->handleUpload($uploadDir, NULL, TRUE, FALSE);
$result['filename'] = $uploader->getUploadName();
if (!empty($result['success']) && !empty($_GET['file_public'])) {
require_once PHPWCMS_ROOT . '/include/inc_lib/dbcon.inc.php';
$data = array('f_pid' => intval($_GET['file_dir']), 'f_uid' => intval($_SESSION["wcs_user_id"]), 'f_kid' => 1, 'f_aktiv' => 1, 'f_public' => 1, 'f_name' => $result['filename'], 'f_created' => now(), 'f_size' => $uploader->getFileSize(), 'f_type' => $uploader->getFileType(), 'f_ext' => strtolower($uploader->getFileExtension()), 'f_longinfo' => slweg($_GET['file_longinfo']), 'f_hash' => md5($result['filename'] . microtime()), 'f_copyright' => slweg($_GET['file_copyright']), 'f_tags' => clean_slweg($_GET['file_tags']));
if (PHPWCMS_CHARSET != 'utf-8') {
$data['f_name'] = makeCharsetConversion($data['f_name'], 'utf-8', PHPWCMS_CHARSET);
$data['f_longinfo'] = makeCharsetConversion($data['f_longinfo'], 'utf-8', PHPWCMS_CHARSET);
$data['f_copyright'] = makeCharsetConversion($data['f_copyright'], 'utf-8', PHPWCMS_CHARSET);
$data['f_tags'] = makeCharsetConversion($data['f_tags'], 'utf-8', PHPWCMS_CHARSET);
}
$insert = _dbInsert('phpwcms_file', $data);
// move uploaded file
if (!empty($insert['INSERT_ID'])) {
$userftppath = PHPWCMS_ROOT . $phpwcms["ftp_path"];
$useruploadpath = PHPWCMS_ROOT . $phpwcms["file_path"];
$usernewfile = $useruploadpath . $data['f_hash'];
if ($data['f_ext']) {
$usernewfile .= '.' . $data['f_ext'];
}
示例2: validateDocShare
public static function validateDocShare(&$docshare)
{
$definition = array('name' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'desc' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'Active' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'boolean'));
$form = new ezcInputForm(INPUT_POST, $definition);
$Errors = array();
if (!$form->hasValidData('name') || $form->name == '') {
$Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('faq/view', 'Please enter name!');
} else {
$docshare->name = $form->name;
}
if ($form->hasValidData('desc') && $form->desc != '') {
$docshare->desc = $form->desc;
} else {
$docshare->desc = '';
}
if ($form->hasValidData('Active') && $form->Active == true) {
$docshare->active = 1;
} else {
$docshare->active = 0;
}
if (empty($Errors)) {
if (isset($_FILES["qqfile"]) && is_uploaded_file($_FILES["qqfile"]["tmp_name"]) && $_FILES["qqfile"]["error"] == 0) {
$objectData = erLhcoreClassModelChatConfig::fetch('doc_sharer');
$dataDocSharer = (array) $objectData->data;
$allowedExtensions = explode(',', $dataDocSharer['supported_extension']);
// max file size in bytes
$sizeLimit = $dataDocSharer['max_file_size'] * 1024 * 1024;
$uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
$result = $uploader->handleUpload('var/tmpfiles/');
if (isset($result['success']) && $result['success'] == 'true') {
$result['filepath'] = $uploader->getFilePath();
$result['filename'] = $uploader->getFileName();
$result['filename_user'] = $uploader->getUserFileName();
$docshare->type = $uploader->getMimeType();
if ($docshare->id == null) {
$docshare->saveThis();
}
$docshare->removeFile();
$photoDir = 'var/storagedocshare/' . date('Y') . 'y/' . date('m') . '/' . date('d') . '/' . $docshare->id;
$photoDirPhoto = 'storagedocshare/' . date('Y') . 'y/' . date('m') . '/' . date('d') . '/' . $docshare->id . '/';
erLhcoreClassFileUpload::mkdirRecursive($photoDir);
$fileName = sha1(sha1($result['filepath']) . time()) . $uploader->getFileExtension();
$photoDir .= '/' . $fileName;
rename($result['filepath'], $photoDir);
$docshare->file_name = $fileName;
$docshare->file_path = $photoDirPhoto;
$docshare->file_name_upload = $result['filename_user'];
$docshare->file_size = $uploader->getFileSize();
$docshare->converted = 0;
$docshare->pdf_to_img_converted = 0;
$docshare->pages_pdf_count = 0;
$docshare->ext = $uploader->getFileExtension();
$docshare->saveThis();
} elseif ($docshare->id == null) {
$Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('faq/view', $result['error']);
}
} elseif ($docshare->id == null) {
$Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('faq/view', 'Please choose a file');
}
}
return $Errors;
}