本文整理汇总了PHP中qqFileUploader::getMimeType方法的典型用法代码示例。如果您正苦于以下问题:PHP qqFileUploader::getMimeType方法的具体用法?PHP qqFileUploader::getMimeType怎么用?PHP qqFileUploader::getMimeType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qqFileUploader
的用法示例。
在下文中一共展示了qqFileUploader::getMimeType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}