/** * @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; }
/** * 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 }
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); }
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(); }
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); }
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; }
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 }
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; }
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)); }
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); }
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; } }
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; }
/** * 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); }
/** * 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')); } }
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); }
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); }
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; }
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 }
function upload($uploadFolder) { $allowedExtensions = array("jpg", "jpeg", "png"); $sizeLimit = 2 * 1024 * 1024; //2 MB $uploader = new qqFileUploader($allowedExtensions, $sizeLimit); return $uploader->handleUpload($uploadFolder); }
public function handleUploadJson($path = '/tmp/') { $sizeLimit = $this->getSizeLimit(); $allowedExtensions = $this->getAllowedExtensionList(); $uploader = new qqFileUploader($allowedExtensions, $sizeLimit); $result = $uploader->handleUpload($path); return htmlspecialchars(json_encode($result), ENT_NOQUOTES); }
public function actionUpload() { $tempFolder = Yii::getPathOfAlias('webroot') . Yii::app()->params['upload_path']; mkdir($tempFolder, 0777, TRUE); mkdir($tempFolder . 'chunks', 0777, TRUE); Yii::import("ext.EFineUploader.qqFileUploader"); $uploader = new qqFileUploader(); $uploader->allowedExtensions = Yii::app()->params['upload_ext']; $uploader->sizeLimit = $this->MAX_UPLOAD_SIZE; //maximum file size in bytes $uploader->chunksFolder = $tempFolder . 'chunks'; $result = $uploader->handleUpload($tempFolder); $result['filename'] = $uploader->getUploadName(); $savedfile = $result['filename']; $result['folder'] = $webFolder; $uploadedFile = $tempFolder . $result['filename']; $uploaded = 1; header("Content-Type: text/plain"); //echo Yii::getPathOfAlias('webroot').Yii::app()->params['upload_path']; if ($uploaded) { $video = new EventMedia(); $video->e_id = 0; $video->path = Yii::app()->params['upload_path'] . $savedfile; if (strstr(mime_content_type(Yii::getPathOfAlias('webroot') . $video->path), "video")) { $video->type = $this->LOCALVID; $video->name = "Local Video"; } elseif (strstr(mime_content_type(Yii::getPathOfAlias('webroot') . $video->path), "image")) { $video->type = $this->IMAGE; $video->name = "Local Image"; //resize image $image = Yii::app()->image->load(Yii::getPathOfAlias('webroot') . $video->path); $image->quality(6); $fname = $video->path; if ($image->__get("width") > 3200) { $pfile = dirname($fname) . "/big." . basename($fname); $image->resize(3200); $image->save(Yii::getPathOfAlias('webroot') . $pfile); } else { $pfile = dirname($fname) . "/big." . basename($fname); $image->save(Yii::getPathOfAlias('webroot') . $pfile); } $pfile = dirname($fname) . "/medium." . basename($fname); $image->resize(800); $image->save(Yii::getPathOfAlias('webroot') . $pfile); $pfile = dirname($fname) . "/small." . basename($fname); $image->resize(400); $image->save(Yii::getPathOfAlias('webroot') . $pfile); } if ($video->save()) { $result['id'] = $video->primaryKey; $result = htmlspecialchars(json_encode($result), ENT_NOQUOTES); echo $result; } } Yii::app()->end(); }
function upload($path, $filename = '', $allowedExtensions = array(), $sizeLimit = 2097152, $replaceOldFile = false) { //create folder if not exist if (!file_exists($path)) { mkdir($path, 0755, true); } $uploader = new qqFileUploader($allowedExtensions, $sizeLimit); $result = $uploader->handleUpload($path, $filename, $replaceOldFile); return $result; }
function subirArchivo() { // list of valid extensions, ex. array("jpeg", "xml", "bmp") $allowedExtensions = array('jpeg', 'png', 'gif', 'jpg'); // max file size in bytes $sizeLimit = 2 * 1024 * 1024; $uploader = new qqFileUploader($allowedExtensions, $sizeLimit); $result = $uploader->handleUpload('assets/uploads/'); // to pass data through iframe you will need to encode all html tags echo htmlspecialchars(json_encode($result), ENT_NOQUOTES); }
public function upload_resources() { // list of valid extensions, ex. array("jpeg", "xml", "bmp") $allowedExtensions = array(); // max file size in bytes $sizeLimit = 50 * 1024 * 1024; $uploader = new qqFileUploader($allowedExtensions, $sizeLimit); $result = $uploader->handleUpload('resources/' . strtolower($_GET['resource_type']) . '/'); // to pass data through iframe you will need to encode all html tags echo htmlspecialchars(json_encode($result), ENT_NOQUOTES); }
public function run() { Yii::import("ext.EAjaxUpload.qqFileUploader"); $allowedExtensions = array("jpg"); $sizeLimit = 200 * 1024 * 1024; $uploader = new qqFileUploader($allowedExtensions, $sizeLimit); $result = $uploader->handleUpload('upload/eajaxupload/'); // to pass data through iframe you will need to encode all html tags $result = htmlspecialchars(json_encode($result), ENT_NOQUOTES); echo $result; }
/** * Processes uploaded file and moves it to disk * @param string $uploadPath The path to upload to * @return string A json encoded string to be sent in response to ajax call */ public function upload($uploadPath) { // list of valid extensions, ex. array("jpeg", "xml", "bmp") $allowedExtensions = $this->getAllowedExtensions(); // max file size in bytes $sizeLimit = $this->getSizeLimit(); $uploader = new qqFileUploader($allowedExtensions, $sizeLimit); $result = $uploader->handleUpload($uploadPath); // to pass data through iframe you will need to encode all html tags return $result; }
public function run() { $controller = $this->getController(); // get the Model Name // $model_class = ucfirst($controller->getId()); // create the Model // $model = new $model_class(); 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, 'articlefiles'); $uploader->inputName = 'tmpFiles'; $result = $uploader->handleUpload($folder); $datasession = Yii::app()->session->itemAt('articlefiles'); 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(720,400); $folder = Yii::getPathOfAlias('webroot').'/uploads/tmp/'; $uploadDirectoryUpload = rtrim($folder,'/'); $check = MHelper::File()->getUniqueTargetPath($uploadDirectoryUpload, $result['tmpFile']); $target = $uploadDirectoryUpload.'/'.$check; 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); $thumb->resize(1000)->save($target); if (copy($target, $tmpFile)){ unlink($target); //delete tmp file } } } $result = htmlspecialchars(json_encode($result), ENT_NOQUOTES); echo $result; }
public function run() { // list of valid extensions, ex. array("jpeg", "xml", "bmp") $allowedExtensions = array("jpg"); // max file size in bytes $sizeLimit = 1 * 1024 * 1024; $uploader = new qqFileUploader($allowedExtensions, $sizeLimit); $result = $uploader->handleUpload('upload/'); // to pass data through iframe you will need to encode all html tags $result = htmlspecialchars(json_encode($result), ENT_NOQUOTES); echo $result; }
protected function saveFile($uploadFolder) { Yii::import("qqFileUploader"); $allowedExtensions = array(); $maxSize = 20 * 1024 * 1024; $uploader = new qqFileUploader($allowedExtensions, $maxSize); $result = $uploader->handleUpload($uploadFolder); if (!isset($result['success'])) { throw new CHttpException(400, Yii::t('app', 'Error saving uploaded file.')); } return $result; }
public function ajaxResponse(\AjaxResponseObject $ajaxResponseObject) { $allowedExtensions = array("zip"); $sizeLimit = return_bytes(ini_get('post_max_size')); // $envid = $_REQUEST["envid"]; $uploader = new qqFileUploader($allowedExtensions, $sizeLimit, $envid); $result = $uploader->handleUpload(PATH_TEMP); // 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; }