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