本文整理汇总了PHP中qqFileUploader类的典型用法代码示例。如果您正苦于以下问题:PHP qqFileUploader类的具体用法?PHP qqFileUploader怎么用?PHP qqFileUploader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了qqFileUploader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: upload
/**
* @brief Accion que se encarga de manipular el proceso de guardar
* un archivo en el servidor
* @param array $allowedExtensions Arreglo de extensiones validas para el archivo
* @param int $sizeLimit Tamaño maximo permitido del fichero que se sube
*/
function upload($allowedExtensions, $sizeLimit = 10485760)
{
jimport('Amadeus.Util.Uploader');
$media =& JComponentHelper::getParams('com_media');
$postSize = $this->toBytes(ini_get('post_max_size'));
$uploadSize = $this->toBytes(ini_get('upload_max_filesize'));
$mediaSize = (int) $media->get('upload_maxsize');
// Se selecciona el minimo tamaño válido para un fichero, de acuerdo
// a los valores configurados en el php, el joomla y el componente.
$sizeLimit = min($postSize, $uploadSize, $mediaSize, $sizeLimit);
// Se alamacena la imagen en la ruta especificada
$uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
$result = $uploader->handleUpload(JPATH_SITE . '/tmp/', true);
if (!isset($result['error'])) {
jimport('Amadeus.Util.Validation');
$file = $uploader->getName();
$result = AmadeusUtilValidation::isValidFile($file, $only_image);
if (isset($result['error'])) {
jimport('joomla.filesystem.file');
if (!JFile::delete($file)) {
$result = array('error' => JText::_('DELETEERROR'));
}
} else {
$this->_file = $file;
}
}
return $result;
}
开发者ID:jmangarret,项目名称:webtuagencia24,代码行数:34,代码来源:File.php
示例2: actionUploadLogo
/**
* Upload logo LbInvoice or LbQuotation
*/
public function actionUploadLogo($sub_cription, $company_id)
{
Yii::import("ext.EAjaxUpload.qqFileUploader");
$folder = 'images/logo/';
// folder for uploaded files
$file_arr = array_diff(scandir($folder), array('.', '..'));
foreach ($file_arr as $key => $file) {
$file_name = explode('.', $file);
$file_name_arr = explode('_', $file_name[0]);
if ($file_name_arr[0] == $sub_cription && $file_name_arr[1] == $company_id) {
unlink($folder . $file);
}
}
$allowedExtensions = array("jpeg", "jpg", "gif", "png");
//array("jpg","jpeg","gif","exe","mov" and etc...
$sizeLimit = 10 * 1024 * 1024;
// maximum file size in bytes
$uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
$result = $uploader->handleUpload($folder, false, $sub_cription, $company_id);
$return = htmlspecialchars(json_encode($result), ENT_NOQUOTES);
$fileSize = filesize($folder . $result['filename']);
//GETTING FILE SIZE
$fileName = $result['filename'];
//GETTING FILE NAME
return $return;
// it's array
}
开发者ID:Lucerin,项目名称:Yii-projects,代码行数:30,代码来源:CLBController.php
示例3: actionSubirDocumento
public function actionSubirDocumento()
{
Yii::import("ext.EAjaxUpload.qqFileUploader");
$folder = Yii::app()->getBasePath() . "/../upload/";
// folder for uploaded files
$allowedExtensions = array("pdf", "zip", "rar", "txt", "cvs", "doc", "docx", "xls", "xlsx", "ppt", "pptx");
//array("jpg","jpeg","gif","exe","mov" and etc...
$sizeLimit = 5 * 1024 * 1024;
// maximum file size in bytes
$uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
$result = $uploader->handleUpload($folder, true);
$return = htmlspecialchars(json_encode($result), ENT_NOQUOTES);
$fileName = $result['filename'];
//GETTING FILE NAME
$fileSize = filesize($folder . $result['filename']);
//GETTING FILE SIZE
$fileExt = $result['ext'];
//GETTING FILE NAME
$documento = new Documento();
$documento->fecha_creacion = date("Y-m-d H:i:s");
$documento->nombre = $fileName;
$documento->usuario_id = Yii::app()->user->id;
$documento->peso = $fileSize;
$documento->extension = $fileExt;
$documento->insert();
echo $return;
// it's array
}
开发者ID:jencina,项目名称:checklist,代码行数:28,代码来源:DocumentoController.php
示例4: datos
function datos($campo_id, $etapa_id)
{
$etapa = Doctrine::getTable('Etapa')->find($etapa_id);
if (UsuarioSesion::usuario()->id != $etapa->usuario_id) {
echo 'Usuario no tiene permisos para subir archivos en esta etapa';
exit;
}
$campo = Doctrine_Query::create()->from('Campo c, c.Formulario.Pasos.Tarea.Etapas e')->where('c.id = ? AND e.id = ?', array($campo_id, $etapa_id))->fetchOne();
if (!$campo) {
echo 'Campo no existe';
exit;
}
// list of valid extensions, ex. array("jpeg", "xml", "bmp")
$allowedExtensions = array('gif', 'jpg', 'png', 'pdf', 'doc', 'docx', 'zip', 'rar', 'ppt', 'pptx', 'xls', 'xlsx', 'mpp', 'vsd');
if (isset($campo->extra->filetypes)) {
$allowedExtensions = $campo->extra->filetypes;
}
// max file size in bytes
$sizeLimit = 20 * 1024 * 1024;
$uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
$result = $uploader->handleUpload('uploads/datos/');
if (isset($result['success'])) {
$file = new File();
$file->tramite_id = $etapa->Tramite->id;
$file->filename = $result['file_name'];
$file->tipo = 'dato';
$file->llave = strtolower(random_string('alnum', 12));
$file->save();
$result['id'] = $file->id;
$result['llave'] = $file->llave;
}
// to pass data through iframe you will need to encode all html tags
echo htmlspecialchars(json_encode($result), ENT_NOQUOTES);
}
开发者ID:chileindica,项目名称:SIMPLE,代码行数:34,代码来源:uploader.php
示例5: admin_add
/**
* Upload attachment
*
* @return void
*/
public function admin_add()
{
$this->set('title_for_layout', __('Add attachment', true));
$allowed_extensions = explode(',', Configure::read('Nodeattachment.allowedFileTypes'));
$size_limit = Configure::read('Nodeattachment.maxFileSize') * 1024 * 1024;
App::import('Vendor', 'Nodeattachment.file-uploader.php');
$uploader = new qqFileUploader($allowed_extensions, $size_limit);
$result = $uploader->handleUpload($this->uploads_path . DS);
$uploader_file_name = $uploader->getFilename();
if (isset($this->params['url']['node_id']) && $uploader_file_name != false) {
$filename['name'] = Inflector::slug($uploader_file_name['filename']);
$filename['ext'] = $uploader_file_name['ext'];
$filename = $this->__uniqeSlugableFilename($filename);
$old_path = $this->uploads_path . DS . $uploader_file_name['filename'] . '.' . $filename['ext'];
$new_path = $this->uploads_path . DS . $filename['name'] . '.' . $filename['ext'];
rename($old_path, $new_path);
$data = array('node_id' => $this->params['url']['node_id'], 'slug' => $filename['name'] . '.' . $filename['ext'], 'path' => '/' . $this->uploads_dir . '/' . $filename['name'] . '.' . $filename['ext'], 'title' => $filename['name'], 'status' => 1, 'mime_type' => $this->__getMime($this->uploads_path . DS . $filename['name'] . '.' . $filename['ext']));
// get shot time of photo
if ($data['mime_type'] == 'image/jpeg' || $data['mime_type'] == 'image/tiff') {
$exif_data = $this->Nodeattachment->getExif($new_path);
if (isset($exif_data['DateTime'])) {
$data['created'] = $exif_data['DateTime'];
}
}
if (!$this->Nodeattachment->save($data)) {
$result = array('error' => __('The Attachment could not be saved. Please, try again.', true));
}
}
Configure::write('debug', 0);
$this->disableCache();
$this->render(false);
echo htmlspecialchars(json_encode($result), ENT_NOQUOTES);
}
开发者ID:ryansnowden,项目名称:nodeattachment,代码行数:38,代码来源:nodeattachment_controller.php
示例6: upload
function upload($data)
{
$max_width = Configure::read('Gallery.max_width');
$thumb_width = Configure::read('Gallery.max_width_thumb');
$thumb_height = Configure::read('Gallery.max_height_thumb');
$thumb_quality = Configure::read('Gallery.quality');
App::import('Vendor', 'Gallery.qqFileUploader', array('file' => 'qqFileUploader.php'));
$uploader = new qqFileUploader();
$result = $uploader->handleUpload($this->dir);
$width = $this->getWidth($this->dir . $result['file']);
$height = $this->getHeight($this->dir . $result['file']);
if ($width > $max_width) {
$scale = $max_width / $width;
$this->resizeImage($this->dir . $result['file'], $width, $height, $scale);
} else {
$scale = 1;
$this->resizeImage($this->dir . $result['file'], $width, $height, $scale);
}
if (empty($thumb_height) && !empty($thumb_width)) {
$this->resizeImage2('resize', $result['file'], $this->dir, 'thumb_' . $result['file'], $thumb_width, FALSE, $thumb_quality);
} elseif (empty($thumb_width) && !empty($thumb_height)) {
$this->resizeImage2('resize', $result['file'], $this->dir, 'thumb_' . $result['file'], FALSE, $thumb_height, $thumb_quality);
} else {
$this->resizeImage2('resizeCrop', $result['file'], $this->dir, 'thumb_' . $result['file'], $thumb_width, $thumb_height, $thumb_quality);
}
$data['Photo']['small'] = 'thumb_' . $result['file'];
$data['Photo']['large'] = $result['file'];
return $data;
}
开发者ID:vitorpacheco,项目名称:gallery,代码行数:29,代码来源:photo.php
示例7: actionUploadAvartar
public function actionUploadAvartar()
{
$id = Yii::app()->request->getParam('id', 0);
$type = Yii::app()->request->getParam('type', 'channel');
if ($type == 'genre') {
$pathUpload = self::_PATH_ICONS_UPLOAD . "genre" . DS;
} elseif ($type == 'collection') {
$pathUpload = self::_PATH_ICONS_UPLOAD . "collection" . DS;
} elseif ($type == 'playlist') {
$pathUpload = self::_PATH_ICONS_UPLOAD . "playlist" . DS;
} elseif ($type == 'album') {
$pathUpload = self::_PATH_ICONS_UPLOAD . "album" . DS;
} else {
$pathUpload = self::_PATH_ICONS_UPLOAD . "channel" . DS;
}
Yii::import("ext.EAjaxUpload.qqFileUploader");
$allowedExtensions = array("png");
//array("jpg","jpeg","gif","exe","mov" and etc...
$sizeLimit = 100 * 1024 * 1024;
// maximum file size in bytes
$uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
$result = $uploader->handleUploadRadio($pathUpload, $id);
if ($result['success']) {
$result['data'] = self::_URL_ICONS_RADIO . $type . '/' . $result['filename'];
} else {
$result['data'] = '';
}
echo CJSON::encode($result);
}
开发者ID:giangnh264,项目名称:mobileplus,代码行数:29,代码来源:DefaultController.php
示例8: actionBase
public function actionBase($id, $name)
{
Yii::import("application.modules.file.components.qqFileUploader");
$temp = Yii::getPathOfAlias('webroot') . DS . 'upload' . DS . 'temp' . DS;
$folderName = $this->getFolder($id, $name);
$dir = Yii::getPathOfAlias('webroot') . DS . 'upload' . DS . $this->module->uploadFolder . DS . $folderName . DS;
//Загрузка файла на сервер
$uploader = new qqFileUploader(Yii::app()->getModule('file')->getAllowedExt(Yii::app()->request->getParam('file_type')), $_GET['sizeLimit']);
$result = $uploader->handleUpload($temp);
$tempFile = Yii::app()->cFile->set($temp . Yii::app()->request->getParam('qqfile'), true);
if (isset($result['success'])) {
$cover = $_GET['cover'] == 'true' ? true : false;
if (in_array(strtolower($tempFile->getExtension()), $this->module->imgExt)) {
$modelId = $this->uploadImage($tempFile, $folderName, $dir, $id, $cover);
} else {
$modelId = $this->uploadFile($tempFile, $folderName, $dir, $id);
}
$html = $this->renderPartial('file_uploader.views._image', array('data' => FileManager::model()->findByPk($modelId), 'cover' => $cover), true);
$tempFile->delete();
}
$html = str_replace("\r\n", '', $html);
$result['imagedata'] = str_replace("\n", '', $html);
$result = json_encode($result);
echo $result;
}
开发者ID:blrtromax,项目名称:seobility,代码行数:25,代码来源:UploadController.php
示例9: run
/**
* Widgets run function
* @param integer $id
* @param string $attribute
* @throws CHttpException
*/
public function run()
{
if (Yii::app()->getRequest()->isPostRequest) {
if (!file_exists($this->uploadPath)) {
throw new CHttpException(Yii::t('zii', 'Invalid upload path'));
}
$uploader = new qqFileUploader($this->allowedExtensions, $this->sizeLimit);
$result = $uploader->handleUpload($this->uploadPath, true, session_id());
$gd = new GdImage();
// step 1: make a copy of the original
$filePath = $this->uploadPath . '/' . $result['filename'];
$copyName = $gd->createName($result['filename'], '_FULLSIZE');
$gd->copy($filePath, $this->uploadPath . '/' . $copyName);
// step 2: Scale down or up this image so it fits in the browser nicely, lets say 500px is safe
$oldSize = $gd->getProperties($filePath);
if ($oldSize['w'] >= $this->resizeWidth) {
$newSize = $gd->getAspectRatio($oldSize['w'], $oldSize['h'], $this->resizeWidth, 0);
$gd->resize($filePath, $newSize['w'], $newSize['h']);
}
echo json_encode($result);
Yii::app()->end();
} else {
throw new CHttpException(Yii::t('zii', 'Invalid request'));
}
}
开发者ID:aakbar24,项目名称:CollegeCorner_Ver_2.0,代码行数:31,代码来源:TbUberUploadAction.php
示例10: actionUploadDocument
public function actionUploadDocument($id)
{
$module_name = "";
if (isset($_REQUEST['module_name'])) {
$module_name = $_REQUEST['module_name'];
}
Yii::import("ext.EAjaxUpload.qqFileUploader");
$folder = 'uploads/';
// folder for uploaded files
$allowedExtensions = array("jpeg", "jpg", "gif", "png", "pdf", "odt", "docx", "doc", "dia");
//array("jpg","jpeg","gif","exe","mov" and etc...
$sizeLimit = 2 * 1024 * 1024;
// maximum file size in bytes
$uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
$result = $uploader->handleUpload($folder, false);
$return = htmlspecialchars(json_encode($result), ENT_NOQUOTES);
$fileSize = filesize($folder . $result['filename']);
//GETTING FILE SIZE
$fileName = $result['filename'];
//GETTING FILE NAME
$documentModel = new LbDocument();
$documentModel->addDocument($module_name, $id, $fileName);
return $return;
// it's array
}
开发者ID:nhuhtlb,项目名称:linxbooks,代码行数:25,代码来源:DefaultController.php
示例11: upload
public function upload($dir = null, $flag = null)
{
// max file size in bytes
$size = Configure::read('AMU.filesizeMB');
if (strlen($size) < 1) {
$size = 4;
}
$relPath = Configure::read('AMU.directory');
if (strlen($relPath) < 1) {
$relPath = "files/" . $_SESSION['User']['company_id'];
}
$sizeLimit = $size * 1024 * 1024;
$this->layout = "ajax";
$directory = WWW_ROOT . DS . $relPath;
if ($dir === null) {
$this->set("result", "{\"error\":\"Upload controller was passed a null value.\"}");
return;
}
// Replace underscores delimiter with slash
$dir = str_replace("___", "/", $dir);
// dir for saving in model
$get_dir = $dir;
$dir = $directory . DS . "{$dir}/";
if (!file_exists($dir)) {
mkdir($dir, 0777, true);
}
if ($flag == 1) {
$allowedExtensions = array('xls', 'xlxs');
}
$uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
$result = $uploader->handleUpload($dir, FALSE, $flag);
$this->set("result", htmlspecialchars(json_encode($result), ENT_NOQUOTES));
$this->_upload_add($result['details']['filename'], $result['details']['ext'], $result['details']['message'], $get_dir);
}
开发者ID:Techmentis,项目名称:flinkiso-lite,代码行数:34,代码来源:FileUploadsController.php
示例12: upload
public function upload($dir = null)
{
// max file size in bytes
$size = Configure::read('AMU.filesizeMB');
if (strlen($size) < 1) {
$size = 4;
}
$relPath = Configure::read('AMU.directory');
if (strlen($relPath) < 1) {
$relPath = "files";
}
$sizeLimit = $size * 1024 * 1024;
$this->layout = "ajax";
Configure::write('debug', 0);
$directory = WWW_ROOT . DS . $relPath;
if ($dir === null) {
$this->set("result", "{\"error\":\"Upload controller was passed a null value.\"}");
return;
}
// Replace underscores delimiter with slash
$dir = str_replace("___", "/", $dir);
$dir = $directory . DS . "{$dir}/";
if (!file_exists($dir)) {
mkdir($dir, 0777, true);
}
$uploader = new qqFileUploader($this->allowedExtensions, $sizeLimit);
$result = $uploader->handleUpload($dir);
$this->set("result", htmlspecialchars(json_encode($result), ENT_NOQUOTES));
}
开发者ID:Numerico-Informatic-Systems-Pvt-Ltd,项目名称:asha,代码行数:29,代码来源:UploadsController.php
示例13: index
public function index()
{
// list of valid extensions, ex. array("jpeg", "xml", "bmp")
$allowedExtensions = array();
// max file size in bytes
$sizeLimit = 10 * 1024 * 1024;
$uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
$multi_dir = '';
if ($this->config->get('multiimageuploader_folder')) {
$multi_dir = "data/";
$multi_dir .= $this->config->get('multiimageuploader_folder');
if (!is_dir(DIR_IMAGE . $multi_dir)) {
mkdir(DIR_IMAGE . $multi_dir, 0777);
}
}
if ($this->config->get('multiimageuploader_segment')) {
if ($this->config->get('multiimageuploader_segment') == "date") {
$multi_dir .= date("Y") . "/";
if (!is_dir(DIR_IMAGE . $multi_dir)) {
mkdir(DIR_IMAGE . $multi_dir, 0777);
}
if (!is_dir(DIR_IMAGE . $multi_dir)) {
mkdir(DIR_IMAGE . $multi_dir, 0777);
}
$multi_dir .= date("m") . "/";
if (!is_dir(DIR_IMAGE . $multi_dir)) {
mkdir(DIR_IMAGE . $multi_dir, 0777);
}
}
}
$result = $uploader->handleUpload(DIR_IMAGE, $multi_dir);
// to pass data through iframe you will need to encode all html tags
echo htmlspecialchars(json_encode($result), ENT_NOQUOTES);
}
开发者ID:bgabor,项目名称:RenaniaOpencart,代码行数:34,代码来源:upload.php
示例14: upload
protected function upload()
{
$tempFolder = Yii::getPathOfAlias('webroot') . self::TMP_DIR;
@mkdir($tempFolder, 0777, TRUE);
@mkdir($tempFolder . 'chunks', 0777, TRUE);
Yii::import("ext.EFineUploader.qqFileUploader");
$uploader = new qqFileUploader();
$uploader->allowedExtensions = array('jpg', 'jpeg', 'png', 'gif');
$uploader->sizeLimit = 7 * 1024 * 1024;
//maximum file size in bytes
$uploader->chunksFolder = $tempFolder . 'chunks';
$result = $uploader->handleUpload($tempFolder);
$result['filename'] = $uploader->getUploadName();
$result['folder'] = $webFolder;
$key = $_POST['key'];
$tmp = new TmpUploads();
$tmp->key = $key;
$tmp->deleteUsersUploads($this->single);
if (!ini_get('file_uploads')) {
$tmp->error('Загрузка файлов запрещена настройками сервера');
return;
}
if (isset($result['error'])) {
$tmp->error($result['error']);
}
$tmp->add(self::TMP_DIR . $result['filename']);
header("Content-Type: text/plain");
$result = htmlspecialchars(json_encode($result), ENT_NOQUOTES);
echo $result;
Yii::app()->end();
}
开发者ID:hit-shappens,项目名称:testapp,代码行数:31,代码来源:AjaxUploadAction.php
示例15: save_image
public function save_image()
{
import('3rdparty.qquploader');
if ($_GET['type'] == 'avatar') {
$type = 'avatar';
} else {
if ($_GET['type'] == 'game') {
$type = 'game';
} else {
if ($_GET['type'] == 'photo') {
$type = 'agent';
} else {
exit("Bad type");
}
}
}
// list of valid extensions, ex. array("jpeg", "xml", "bmp")
$allowedExtensions = array('jpeg', 'png', 'jpg');
// max file size in bytes
$sizeLimit = 1 * 1024 * 1024;
$uploader = new \qqFileUploader($allowedExtensions, $sizeLimit);
$result = $uploader->handleUpload("img/{$type}/", False, True);
$file = "{$result['filename']}.{$result['ext']}";
if ($type == 'avatar') {
$this->thumb_image($file, 'avatar', 80);
} else {
if ($type == 'game') {
$this->thumb_image($file, 'game', 120);
}
}
// to pass data through iframe you will need to encode all html tags
echo htmlspecialchars(json_encode($result), ENT_NOQUOTES);
}
开发者ID:radiosilence,项目名称:trouble,代码行数:33,代码来源:put.php
示例16: ajaxResponse
public function ajaxResponse(\AjaxResponseObject $ajaxResponseObject)
{
// list of valid extensions, ex. array("jpeg", "xml", "bmp")
$allowedExtensions = array();
// max file size in bytes
$sizeLimit = return_bytes(ini_get('post_max_size'));
$destId = $_REQUEST["destid"];
$destObject = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $destId);
//remove old image
$oldImageId = $destObject->get_attribute("bid:portlet:msg:picture_id");
if ($oldImageId !== 0) {
$oldImage = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $oldImageId);
if ($oldImage instanceof \steam_document) {
$destObject->delete_attribute("bid:portlet:msg:picture_id");
$oldImage->delete();
}
}
// upload image
$envid = $destObject->get_environment()->get_id();
$uploader = new qqFileUploader($allowedExtensions, $sizeLimit, $envid);
$result = $uploader->handleUpload(PATH_TEMP);
// set new image
$destObject->set_attribute("bid:portlet:msg:picture_id", $result["oid"]);
// to pass data through iframe you will need to encode all html tags
echo htmlspecialchars(json_encode($result), ENT_NOQUOTES);
die;
//$ajaxResponseObject->setStatus("ok");
//return $ajaxResponseObject;
}
开发者ID:rolwi,项目名称:koala,代码行数:29,代码来源:UploadImage.class.php
示例17: fileupload_trigger_check
function fileupload_trigger_check()
{
if (intval(get_query_var('postform_fileupload')) == 1) {
if (!(get_option('bbp_5o1_toolbar_allow_image_uploads') && (is_user_logged_in() || get_option('bbp_5o1_toolbar_allow_anonymous_image_uploads')))) {
echo htmlspecialchars(json_encode(array("error" => __("You are not permitted to upload images.", 'bbp_5o1_toolbar'))), ENT_NOQUOTES);
exit;
}
require_once dirname(__FILE__) . '/includes/fileuploader.php';
// list of valid extensions, ex. array("jpeg", "xml", "bmp")
$allowedExtensions = array('jpg', 'jpeg', 'png', 'gif');
// Because using Extensions only is very bad.
$allowedMimes = array(IMAGETYPE_JPEG, IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_GIF);
// max file size in bytes
$sizeLimit = bbp_5o1_images_panel::return_bytes(min(array(ini_get('post_max_size'), ini_get('upload_max_filesize'))));
$uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
$directory = wp_upload_dir();
$result = $uploader->handleUpload(trailingslashit($directory['path']));
$mime = exif_imagetype($result['file']);
if (!$mime || !in_array($mime, $allowedMimes)) {
$deleted = unlink($result['file']);
echo htmlspecialchars(json_encode(array("error" => __("Disallowed file type.", 'bbp_5o1_toolbar'))), ENT_NOQUOTES);
exit;
}
// Construct the attachment array
$attachment = array('post_mime_type' => $mime ? image_type_to_mime_type($mime) : '', 'guid' => trailingslashit($directory['url']) . $result['filename'], 'post_parent' => 0, 'post_title' => $result['name'], 'post_content' => 'Image uploaded for a forum topic or reply.');
// Save the data
$id = wp_insert_attachment($attachment, $result['file'], 0);
$result['id'] = $id;
$result['attachment'] = $attachment;
$result = array("success" => true, "file" => $attachment['guid']);
echo htmlspecialchars(json_encode($result), ENT_NOQUOTES);
exit;
}
}
开发者ID:sayf75,项目名称:bbPress-Post-Toolbar,代码行数:34,代码来源:toolbar-images-panel.php
示例18: main
public function main()
{
// Post CODE is to let the uploader know what to do with the file when complete.
$code = $_POST['code'];
$this->ajax = true;
// Include the uploader class
$uploader = new qqFileUploader();
// Specify the list of valid extensions, ex. array("jpeg", "xml", "bmp")
$uploader->allowedExtensions = array();
// Specify max file size in bytes.
$uploader->sizeLimit = 10 * 1024 * 1024;
// Specify the input name set in the javascript.
$uploader->inputName = 'qqfile';
// If you want to use resume feature for uploader, specify the folder to save parts.
$uploader->chunksFolder = config::AJAX_CHUNK_FOLDER;
// Call handleUpload() with the name of the folder, relative to PHP's getcwd()
$result = $uploader->handleUpload(config::AJAX_UPLOAD_FOLDER);
// To save the upload with a specified name, set the second parameter.
// $result = $uploader->handleUpload('uploads/', md5(mt_rand()).'_'.$uploader->getName());
// To return a name used for uploaded file you can use the following line.
$result['uploadName'] = $uploader->getUploadName();
if ($result['uploadName']) {
$this->processFile($result['uploadName'], $code);
}
// Lets just save this in a universal holding pattern.
header("Content-Type: text/plain");
echo json_encode($result);
}
开发者ID:carriercomm,项目名称:atikit,代码行数:28,代码来源:upload.php
示例19: actionUpload
public function actionUpload()
{
Yii::import("ext.MyAcrop.qqFileUploader");
$folder = 'uploads/tmp';
// folder for uploaded files
// $allowedExtensions = array("jpg","jpeg","gif","png");
$allowedExtensions = array();
$sizeLimit = Yii::app()->params['storeImages']['maxFileSize'];
$uploader = new qqFileUploader($allowedExtensions, $sizeLimit, $this->uploadlogosession);
$uploader->inputName = 'photo';
$result = $uploader->handleUpload($folder);
$datasession = Yii::app()->session->itemAt($this->uploadlogosession);
if (!empty($datasession)) {
end($datasession);
$key = key($datasession);
$result['tmpFile'] = $datasession[$key];
$tmpFile = Yii::getPathOfAlias('webroot') . '/uploads/tmp/' . $result['tmpFile'];
if (file_exists($tmpFile)) {
$thumbTo = array(160, 160);
$folder = Yii::getPathOfAlias('webroot') . '/uploads/tmp/';
$uploadDirectoryUpload = rtrim($folder, '/');
$check = MHelper::File()->getUniqueTargetPath($uploadDirectoryUpload, $result['tmpFile']);
$target = $uploadDirectoryUpload . '/' . $check;
// if (copy($tmpFile, $target)){
Yii::import('ext.phpthumb.PhpThumbFactory');
$thumb = PhpThumbFactory::create($tmpFile);
$sizes = Yii::app()->params['storeImages']['sizes'];
$method = $sizes['resizeThumbMethod'];
$thumb->{$method}($thumbTo[0], $thumbTo[1])->save($target);
if (copy($target, $tmpFile)) {
unlink($target);
//delete tmp file
}
/* $result['tmpFile'] = $check;
$data_sess = array();
if(Yii::app()->session->itemAt($this->uploadlogosession)){
$data = Yii::app()->session->itemAt($this->uploadlogosession);
if(!is_array($data)){
$data_sess[$key] = $check;
} else {
$data[$key] = $check;
$data_sess = $data;
}
} else {
$data_sess[$key] = $check;
}
Yii::app()->session->remove($this->uploadlogosession);
Yii::app()->session->add($this->uploadlogosession, $data_sess);
unlink($tmpFile); //delete tmp file
*/
// }
}
}
$result = htmlspecialchars(json_encode($result), ENT_NOQUOTES);
echo $result;
}
开发者ID:Aplay,项目名称:anetika_site,代码行数:60,代码来源:ProfileController.php
示例20: upload
function upload($uploadFolder)
{
$allowedExtensions = array("jpg", "jpeg", "png");
$sizeLimit = 2 * 1024 * 1024;
//2 MB
$uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
return $uploader->handleUpload($uploadFolder);
}
开发者ID:haleystorm,项目名称:paradise,代码行数:8,代码来源:file-uploader.php
注:本文中的qqFileUploader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论