本文整理汇总了PHP中Upload::Clean方法的典型用法代码示例。如果您正苦于以下问题:PHP Upload::Clean方法的具体用法?PHP Upload::Clean怎么用?PHP Upload::Clean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Upload
的用法示例。
在下文中一共展示了Upload::Clean方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
function asignar_cotizacion($id_equipo, $placa_inventario)
{
App::import('Vendor', 'upload', array('file' => 'class.upload.php'));
$this->autoLayout = false;
$this->autoRender = false;
$datos_json = array('resultado' => false, 'id' => '', 'nombre_archivo' => '');
if (!empty($_FILES) && !empty($id_equipo) && !empty($placa_inventario)) {
if (!empty($_FILES['cotizacion']['name'])) {
$handle = new Upload($_FILES['cotizacion']);
if ($handle->uploaded) {
$handle->file_overwrite = true;
$handle->file_safe_name = false;
$handle->file_auto_rename = false;
$handle->file_new_name_body = 'cotizacion(' . $this->Cotizacion->getNextAutoIncrement() . ')_' . $placa_inventario;
$handle->Process('equipos/cotizaciones');
if ($handle->processed) {
$this->data['Cotizacion']['nombre_archivo'] = $handle->file_dst_name;
$this->data['Cotizacion']['id_equipo'] = $id_equipo;
$this->data['Cotizacion']['placa_inventario'] = $placa_inventario;
if ($this->Cotizacion->save($this->data)) {
$datos_json['resultado'] = true;
$datos_json['id'] = $this->Cotizacion->id;
$datos_json['nombre_archivo'] = $this->data['Cotizacion']['nombre_archivo'];
}
}
$handle->Clean();
}
}
}
return json_encode($datos_json);
}
示例2: imgUpload
/**
* @desc sube una imagen jpg al servidor
* @param void
* @return void
*/
private function imgUpload()
{
$msg = "";
$dir = IMG_LOCAL_PATH . "eventos/" . $this->_event_id;
$dirweb = IMG_WEB_PATH . "eventos/" . $this->_event_id;
$handle = new Upload($_FILES['urlfoto']);
if ($handle->uploaded) {
// movemos de temp a dir final
$handle->Process($dir);
// we check if everything went OK
if ($handle->processed) {
// everything was fine !
$msg .= '!Carga exitosa!:
<a href="' . $dirweb . '/' . $handle->file_dst_name . '">' . $handle->file_dst_name . '</a>';
} else {
// one error occured
$msg .= '<fieldset>';
$msg .= ' <legend>No es posible mover la imagen en la ruta indicada</legend>';
$msg .= ' Error: ' . $handle->error . '';
$msg .= '</fieldset>';
}
// we delete the temporary files
$handle->Clean();
} else {
// if we're here, the upload file failed for some reasons
// i.e. the server didn't receive the file
$msg .= '<fieldset>';
$msg .= ' <legend>No es pposible cargar la imagen al servidor.</legend>';
$msg .= ' Error: ' . $handle->error . '';
$msg .= '</fieldset>';
}
return $msg;
}
示例3: __construct
public function __construct($feed, $type)
{
$this->feedArray = $feed;
$this->feedType = $type;
$this->size = '1000000';
$maxSize = $this->size / 1000000;
if ($this->feedType == 'text') {
$this->feedText = $feed;
} else {
if ($this->feedType == 'img') {
$this->feedImg = $feed['image'];
$this->feedText = $feed['text'];
$this->newName = $_SESSION['isv_user_id'] . str_replace(' ', '', microtime());
$this->newName = str_replace('.', '', $this->newName);
$path = ISVIPI_UPLOADS_BASE . 'feeds/';
//check file size
if ($this->feedImg["size"] > $this->size) {
$array['err'] = true;
$array['message'] = 'The file is too large. Maximum file size is ' . $maxSize . ' MB.';
echo json_encode($array);
exit;
}
//check file type
if ($this->feedImg["type"] != "image/jpg" && $this->feedImg["type"] != "image/png" && $this->feedImg["type"] != "image/jpeg" && $this->feedImg["type"] != "image/gif") {
$array['err'] = true;
$array['message'] = 'Allowed file types are .jpg .jpeg .png .gif';
echo json_encode($array);
exit;
}
//require file upload class
require_once ISVIPI_CLASSES_BASE . 'utilities/class.upload.php';
$newUpload = new Upload($this->feedImg);
$newUpload->file_new_name_body = ISVIPI_600 . $this->newName;
$newUpload->image_resize = true;
$newUpload->image_convert = 'jpg';
$newUpload->image_x = 600;
$newUpload->image_ratio_y = true;
$newUpload->Process($path);
if (!$newUpload->processed) {
$array['err'] = true;
$array['message'] = 'An error occurred: ' . $newUpload->error . '';
echo json_encode($array);
exit;
}
$newUpload->Clean();
}
}
/** add our feed to the database **/
$this->addFeed();
/** return success **/
$array['err'] = false;
echo json_encode($array);
exit;
}
示例4: save
/**
* Logic to save an item
*
* @access public
* @return void
* @since 1.0
*/
function save()
{
// Check for request forgeries
JRequest::checkToken() or jexit('Invalid Token');
jimport('joomla.filesystem.file');
jimport('joomla.filesystem.archive');
require_once HOTELGUIDE_ADMINISTRATOR . DS . 'lib' . DS . 'class.upload.php';
$task = JRequest::getVar('task');
$post = JRequest::get('post');
$model = $this->getModel('admanager');
$data = $model->getFile($post['id']);
if (isset($_FILES['file_upload'])) {
$handle = new Upload($_FILES['file_upload']);
if ($handle->uploaded) {
$dir = HOTELGUIDE_IMAGES_BANNER . DS;
if (!file_exists($dir)) {
mkdir($dir, 0777);
}
$handle->jpeg_quality = 100;
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$width = $handle->image_src_x;
$height = $handle->image_src_y;
$handle->file_new_name_body = $file_body;
$handle->Process($dir);
$post['filename'] = $handle->file_dst_name;
$post['imagewidth'] = $width;
$post['imageheight'] = $height;
$handle->Clean();
}
}
if ($model->store($post)) {
switch ($task) {
case 'apply':
$link = 'index.php?option=com_hotelguide&view=admanager&cid[]=' . (int) $model->get('id');
break;
default:
$link = 'index.php?option=com_hotelguide&view=admanagers';
break;
}
$msg = JText::_('HG_AD_ITEM_SAVED');
$cache =& JFactory::getCache('com_hotelguide');
$cache->clean();
} else {
$msg = JText::_('HG_ERROR_SAVING_ITEM');
JError::raiseError(500, $model->getError());
$link = 'index.php?option=com_hotelguide&view=admanager';
}
$model->checkin();
$this->setRedirect($link, $msg);
}
示例5: save
/**
* save a record (and redirect to main page)
* @return void
*/
function save()
{
JRequest::checkToken() or jexit('Invalid Token');
jimport('joomla.filesystem.file');
jimport('joomla.filesystem.archive');
require_once HOTELGUIDE_ADMINISTRATOR . DS . 'lib' . DS . 'class.upload.php';
$post = JRequest::get('post');
$file = JRequest::getVar('file_upload', '', 'files', 'array');
$task = JRequest::getVar('task');
$model =& $this->getModel('facility');
$filename = '';
if (isset($_FILES['file_upload'])) {
$filename = $_FILES['file_upload']['name'];
$post['pictogram'] = $filename;
$handle = new Upload($_FILES['file_upload']);
if ($handle->uploaded) {
$dir = HOTELGUIDE_IMAGES_PICTOGRAM . DS;
if (!file_exists($dir)) {
mkdir($dir, 0777);
}
$handle->jpeg_quality = 100;
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$width = $handle->image_src_x;
$height = $handle->image_src_y;
$handle->Process($dir);
$handle->Clean();
}
}
if ($model->store($post)) {
switch ($task) {
case 'apply':
$link = 'index.php?option=com_hotelguide&view=facility&cid[]=' . (int) $model->get('id');
break;
case 'saveandnew':
$link = 'index.php?option=com_hotelguide&view=facility';
break;
default:
$link = 'index.php?option=com_hotelguide&view=facilities';
break;
}
$msg = JText::_('HG_FACILITY_SAVED');
} else {
$link = 'index.php?option=com_hotelguide&view=facilities';
$msg = JText::_('HG_ERROR_SAVING_FACILITY');
}
$this->setRedirect($link, $msg);
}
示例6: upload
public function upload($curso_id)
{
$msg = false;
$handle = new Upload($_FILES['agenda']);
if ($handle->uploaded) {
$handle->Process('files');
if ($handle->processed) {
rename(FILES_PATH . $handle->file_dst_name, FILES_PATH . $curso_id . ".pdf");
return 1;
} else {
$msg = $handle->error;
}
$handle->Clean();
} else {
$msg = $handle->error;
}
return $msg;
}
示例7: img_upload
private function img_upload($clinic_id)
{
if (Login::get_instance()->check_login() == 'valid') {
$user_data = Register::get_instance()->get_current_user();
if ($user_data['status'] != 10) {
exit;
}
$foo = new Upload($_FILES['clinic_img']);
if ($foo->uploaded) {
$this->del($clinic_id);
$ds = DIRECTORY_SEPARATOR;
$storeFolder = '..' . $ds . 'views' . $ds . 'clinics_img';
$targetPath = dirname(__FILE__) . $ds . $storeFolder . $ds;
$targetName = $clinic_id . '_' . md5(rand(1, 5000000000));
while (file_exists($targetName)) {
$targetName = $clinic_id . '_' . md5(rand(1, 5000000000));
}
$targetFile = $targetPath . $targetName . '.jpeg';
$foo->file_new_name_body = $targetName;
$foo->image_resize = true;
$foo->image_convert = 'jpeg';
$foo->image_x = 1024;
$foo->image_y = 768;
$foo->image_ratio_crop = false;
//$foo->image_ratio_y = true;
$foo->Process($targetPath);
if ($foo->processed) {
$foo->Clean();
Operations::get_instance()->init(array('img_name' => $targetName . '.jpeg', 'clinic_id' => $clinic_id, 'time_added' => time(), 'date_added' => TimeTools::get_time_id(date('Y-m-d'))), 'clinics_img', 'update');
}
}
}
}
示例8: onJosettaSaveItem
/**
* Save an item after it has been translated
* This will be called by Josetta when a user clicks
* the Save button. The context is passed so
* that each plugin knows if it must process the data or not
*
* if $item->reference_id is empty, this is
* a new item, otherwise we are updating the item
*
* $item->data contains the fields entered by the user
* that needs to be saved
*
*@param context type
*@param data in form of array
*
*return table id if data is inserted
*
*return false if error occurs
*
*/
public function onJosettaSaveItem($context, $item, &$errors)
{
if ($context != $this->_context) {
return;
}
// load languages for form and error messages
$this->loadLanguages();
// Save
jimport('joomla.filesystem.file');
JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_k2/tables');
require_once JPATH_ADMINISTRATOR . '/components/com_k2/lib/class.upload.php';
$row = JTable::getInstance('K2Category', 'Table');
$params = JComponentHelper::getParams('com_k2');
if (!$row->bind($item)) {
JosettaHelper::enqueueMessages($row->getError());
return false;
}
$row->parent = (int) $row->parent;
//$input = JRequest::get('post');
$filter = JFilterInput::getInstance();
$categoryParams = new JRegistry($row->params);
$categoryParams->set('catMetaDesc', $filter->clean($item['metadesc']));
$categoryParams->set('catMetaKey', $filter->clean($item['metakey']));
$row->params = $categoryParams->toString();
$isNew = $row->id ? false : true;
//Trigger the finder before save event
$dispatcher = JDispatcher::getInstance();
JPluginHelper::importPlugin('finder');
$results = $dispatcher->trigger('onFinderBeforeSave', array('com_k2.category', $row, $isNew));
if ($params->get('xssFiltering')) {
$filter = new JFilterInput(array(), array(), 1, 1, 0);
$row->description = $filter->clean($row->description);
}
if (!$row->id) {
$row->ordering = $row->getNextOrder('parent = ' . $row->parent . ' AND trash=0');
}
$savepath = JPATH_ROOT . '/media/k2/categories/';
if ($row->image && JFile::exists($savepath . $image)) {
$uniqueName = uniqid() . '.jpg';
JFile::copy($savepath . $row->image, $savepath . $uniqueName);
$row->image = $uniqueName;
}
if (!$row->check()) {
JosettaHelper::enqueueMessages($row->getError());
return false;
}
if (!$row->store()) {
JosettaHelper::enqueueMessages($row->getError());
return false;
}
if (!$params->get('disableCompactOrdering')) {
$row->reorder('parent = ' . $row->parent . ' AND trash=0');
}
if ((int) $params->get('imageMemoryLimit')) {
ini_set('memory_limit', (int) $params->get('imageMemoryLimit') . 'M');
}
//$files = JRequest::get('files');
$savepath = JPATH_ROOT . '/media/k2/categories/';
// TODO: this will be renamed when used through Josetta
//$existingImage = JRequest::getVar('existingImage');
if (!empty($item['files']) && !empty($item['files']['image'])) {
if (($item['files']['image']['error'] === 0 || !empty($item['existingImage'])) && empty($item['del_image'])) {
if ($item['files']['image']['error'] === 0) {
$image = $item['files']['image'];
} else {
$image = JPATH_SITE . '/' . JPath::clean($item['existingImage']);
}
$handle = new Upload($image);
if ($handle->uploaded) {
$handle->file_auto_rename = false;
$handle->jpeg_quality = $params->get('imagesQuality', '85');
$handle->file_overwrite = true;
$handle->file_new_name_body = $row->id;
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_x = $params->get('catImageWidth', '100');
$handle->Process($savepath);
if ($files['image']['error'] === 0) {
$handle->Clean();
}
//.........这里部分代码省略.........
示例9: processLogo
function processLogo()
{
if ( !isset($_FILES['original_logo']) ) return FALSE;
global $connections;
// Uses the upload.class.php to handle file uploading and image manipulation.
// GPL PHP upload class from http://www.verot.net/php_class_upload.htm
require_once(WP_PLUGIN_DIR . '/connections/includes/php_class_upload/class.upload.php');
$process_logo = new Upload($_FILES['original_logo']);
if ($process_logo->uploaded)
{
$connections->setSuccessMessage('image_uploaded');
// Creates the logo image and saves it to the wp_content/connection_images/ dir.
// If needed this will create the upload dir and chmod it.
$process_logo->allowed = array('image/jpeg','image/gif','image/png');
$process_logo->auto_create_dir = TRUE;
$process_logo->auto_chmod_dir = TRUE;
$process_logo->file_safe_name = TRUE;
$process_logo->file_auto_rename = TRUE;
$process_logo->file_name_body_add= '_logo';
$process_logo->image_convert = 'jpg';
$process_logo->jpeg_quality = $connections->options->getImgLogoQuality();
$process_logo->image_resize = TRUE;
$process_logo->image_ratio_crop = (bool) $connections->options->getImgLogoRatioCrop();
$process_logo->image_ratio_fill = (bool) $connections->options->getImgLogoRatioFill();
$process_logo->image_y = $connections->options->getImgLogoY();
$process_logo->image_x = $connections->options->getImgLogoX();
$process_logo->Process(CN_IMAGE_PATH);
if ($process_logo->processed) {
$connections->setSuccessMessage('image_thumbnail');
$logo['name'] = $process_logo->file_dst_name;
} else {
$connections->setErrorMessage('image_thumbnail_failed');
return FALSE;
}
$process_logo->Clean();
}
else
{
$connections->setErrorMessage('image_upload_failed');
return FALSE;
}
return $logo;
}
示例10: save
//.........这里部分代码省略.........
JFile::delete($thumb_dir . $filename);
}
} else {
$post['filename' . $seq] = $filename;
}
if (isset($_FILES['file_upload' . $seq])) {
$handle = new Upload($_FILES['file_upload' . $seq]);
if ($handle->uploaded) {
// Original image
$dir = HOTELGUIDE_IMAGES_GALLERY . DS . $directory . DS . 'album' . DS;
if (!file_exists($dir)) {
mkdir($dir, 0777);
}
$resize_dir = HOTELGUIDE_IMAGES_GALLERY . DS . $directory . DS . 'resize' . DS;
if (!file_exists($resize_dir)) {
mkdir($resize_dir, 0777);
}
$thumb_dir = HOTELGUIDE_IMAGES_GALLERY . DS . $directory . DS . 'thumb' . DS;
if (!file_exists($thumb_dir)) {
mkdir($thumb_dir, 0777);
}
if (JFile::exists($dir . $filename)) {
JFile::delete($dir . $filename);
}
if (JFile::exists($resize_dir . $filename)) {
JFile::delete($resize_dir . $filename);
}
if (JFile::exists($thumb_dir . $filename)) {
JFile::delete($thumb_dir . $filename);
}
$handle->jpeg_quality = 100;
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$width = $handle->image_src_x;
$height = $handle->image_src_y;
$handle->file_new_name_body = $file_body;
$handle->Process($dir);
$post['filename' . $seq] = $handle->file_dst_name;
// resized image
$handle->image_resize = true;
if ($height < $width) {
$handle->image_ratio_y = true;
$handle->image_x = 240;
//$imageWidth;
} else {
$handle->image_ratio_x = true;
$handle->image_y = 240;
//$imageHeight;
}
$handle->jpeg_quality = 85;
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $file_body;
$handle->Process($resize_dir);
$imagewidth = $handle->image_dst_x;
$imageheight = $handle->image_dst_y;
$post['imagewidth'] = $imagewidth;
$post['imageheight'] = $imageheight;
// thumbnail image
$handle->image_resize = true;
if ($height < $width) {
$handle->image_ratio_y = true;
$handle->image_x = 64;
//$imageWidth;
} else {
$handle->image_ratio_x = true;
$handle->image_y = 64;
//$imageHeight;
}
$handle->jpeg_quality = 85;
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $file_body;
$handle->Process($thumb_dir);
$handle->Clean();
}
}
}
if ($model->store($post)) {
switch ($task) {
case 'apply':
$link = 'index.php?option=com_hotelguide&view=roomitem&cid[]=' . (int) $model->get('id');
break;
case 'saveandnew':
$link = 'index.php?option=com_hotelguide&view=roomitem';
break;
default:
$link = 'index.php?option=com_hotelguide&view=roomitems';
break;
}
$msg = JText::_('HG_ROOM_ITEM_SAVED');
$cache =& JFactory::getCache('com_hotelguide');
$cache->clean();
} else {
$msg = JText::_('HG_ERROR_SAVING_ITEM');
$link = 'index.php?option=com_hotelguide&view=roomitem';
}
$model->checkin();
$this->setRedirect($link, $msg);
}
示例11: date
$document->image_resize = true;
$document->image_ratio_pixels = 200000;
$document->image_overlay_color = '#505050';
$document->image_overlay_opacity = 75;
$document->image_text = $text;
$document->image_text_color = '#ffffff';
$document->image_text_opacity = 100;
$document->image_text_background_opacity = 50;
$document->image_text_font = 5;
$document->image_text_padding = 20;
$document->file_new_name_body = 'image';
$document->Process('../img/');
if ($document->processed) {
//si edition faite... détection de la date, du path du fichier
$date = date("Y-m-d H:i:s");
$name = $document->file_dst_name;
//enregistrement dans la base de donnee des infos
$req2 = $req->prepare('INSERT INTO images(name, date, ip) VALUES(:name, :date, :ip)');
$req2->execute(array('name' => $name, 'date' => $date, 'ip' => $ip));
$document->Clean();
$alert = '<section id="alert"><p>Mauvais type de fichier, ca fichier... :/</p></section>';
header('Location: ../index.php');
exit;
} else {
$alert = 'error : ' . $document->error;
}
}
} else {
$alert = 'Mauvais type de fichier, ca fichier... :/ ';
}
}
示例12: imageFrame
function imageFrame($filename = false, $framefile = false)
{
global $IMAGE, $CONFIG;
if (array_key_exists('mobile', $CONFIG)) {
include APP . LIBS . 'class_image_upload/class.upload.php';
} else {
include LIBS . 'class_image_upload/class.upload.php';
}
deleteFile($filename, 'imageFramed');
// pr($IMAGE[0]['pathfile'].$filename);
$handle = new Upload($IMAGE[0]['pathfile'] . $filename);
// pr($handle);
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->image_x = 180;
$handle->image_y = 181;
$handle->image_ratio_crop = false;
$handle->jpeg_quality = 100;
$handle->image_watermark = $IMAGE[0]['pathframe'] . $framefile;
$handle->Process($IMAGE[0]['imageframed']);
if ($handle->processed) {
$filename = $handle->file_dst_name;
} else {
echo 'Error: ' . $handle->error . '';
}
$handle->Clean();
return true;
} else {
echo 'Error: ' . $handle->error . '';
}
return false;
}
示例13: header
if ($foo->uploaded) {
// save uploaded image with no changes
// save uploaded image with a new name
$foo->file_new_name_body = 'foo';
$foo->Process($_SERVER['DOCUMENT_ROOT'] . '/inventory2/logo/');
if ($foo->processed) {
} else {
//echo 'error : ' . $foo->error;
}
$foo->file_new_name_body = $s_id;
$foo->image_resize = true;
$foo->image_convert = 'jpg';
$foo->image_x = 100;
$foo->image_ratio_y = true;
$foo->Process($_SERVER['DOCUMENT_ROOT'] . '/inventory2/logo/');
if ($foo->processed) {
$foo->Clean();
} else {
//echo 'error : ' . $foo->error;
}
}
$file = $_SERVER['DOCUMENT_ROOT'] . '/inventory2/logo/' . $s_id . '.jpg';
//echo $file;
if (is_file($file)) {
} else {
$file = $_SERVER['DOCUMENT_ROOT'] . '/inventory2/logo/' . $s_id . '.png';
if (is_file($file)) {
}
}
header("Location: ?folder=store&file=view");
}
示例14: uploadFile
public function uploadFile($idR, $campoFile = "file_", $campoEtichetta = "et_file_", $campoCanc = "canc_")
{
$nFile = $this->get_nfile();
if ($nFile > 0) {
//recupero i file già inseriti
$query = sprintf("select * from file where fk_tabella = %d and fk_record = %d order by sorting", $this->idTabella, $idR);
$this->conn->query($query);
$arrayFile = array();
while ($rowFile = $this->conn->fetch()) {
$arrayFile[] = array("idF" => $rowFile["idF"], "file" => $rowFile["file"], "etichetta" => $rowFile["titoloF"]);
}
$arr_file = array();
$arr_etichette = array();
$dir_dest = "../" . $this->folder_upload . "/" . $this->get_cartella();
for ($i = 1; $i <= $nFile; $i++) {
$nomeCampoFile = $this->campo . "_" . $campoFile . $i;
$nomeCampoEtichetta = $this->campo . "_" . $campoEtichetta . $i;
$nomeCampoCanc = $this->campo . $campoCanc . $i;
if (isset($_FILES[$nomeCampoFile]) and $_FILES[$nomeCampoFile]["size"] > 0) {
if (!($handle = new Upload($_FILES[$nomeCampoFile]))) {
exit('error : ' . $handle->error);
}
$handle->no_script = false;
$handle->file_overwrite = true;
$handle->Process($dir_dest);
if ($handle->processed) {
$destname = $handle->file_dst_name;
$filenamemd5 = md5_file($dir_dest . "/" . $destname);
//controllo se è una immagine e se devo fare ridimensionamento
if ($this->tipo == "img") {
if ($handle->file_is_image) {
$tipoRid = $this->get_tipo_ridim();
if ($tipoRid == 3) {
$handle_img = new Upload($dir_dest . "/" . $destname);
$ext = $handle_img->file_src_name_ext;
//estensione del file
//recupero le dimensioni da fissare
$arrayDim = $this->get_dimensioni();
if ($handle_img->image_src_x > $handle_img->image_src_y) {
$widthB = $arrayDim[0];
$widthT = $arrayDim[2];
if ($handle_img->image_src_x > $widthB) {
$handle_img->image_resize = true;
$handle_img->image_ratio_y = true;
$handle_img->image_x = $widthB;
$handle_img->file_overwrite = true;
$handle_img->Process($dir_dest);
}
$handle_img->file_new_name_body = $filenamemd5;
$handle_img->file_overwrite = true;
$handle_img->Process($dir_dest);
if ($widthT > 0) {
if ($handle_img->image_src_x > $widthT) {
$handle_img->image_resize = true;
$handle_img->image_ratio_y = true;
$handle_img->image_x = $widthT;
}
$handle_img->file_new_name_body = $filenamemd5 . "_thumb";
$handle_img->file_overwrite = true;
$handle_img->Process($dir_dest);
}
} else {
$heightB = $arrayDim[1];
$heightT = $arrayDim[3];
if ($handle_img->image_src_y > $heightB) {
$handle_img->image_resize = true;
$handle_img->image_ratio_x = true;
$handle_img->image_y = $heightB;
$handle_img->file_overwrite = true;
$handle_img->Process($dir_dest);
}
$handle_img->file_new_name_body = $filenamemd5;
$handle_img->file_overwrite = true;
$handle_img->Process($dir_dest);
if ($heightT > 0) {
if ($handle_img->image_src_y > $heightT) {
$handle_img->image_resize = true;
$handle_img->image_ratio_x = true;
$handle_img->image_y = $heightT;
}
$handle_img->file_new_name_body = $filenamemd5 . "_thumb";
$handle_img->file_overwrite = true;
$handle_img->Process($dir_dest);
}
}
$handle_img->Clean();
}
} else {
exit("error: il file caricato non è una immagine");
}
} else {
$ext = $handle->file_src_name_ext;
$handle->file_new_name_body = $filenamemd5;
$handle->no_script = false;
$handle->file_overwrite = true;
$handle->Process($dir_dest);
}
//cancello il file caricato con il nome originale e faccio pulizia
@unlink($dir_dest . "/" . $destname);
$handle->Clean();
//.........这里部分代码省略.........
示例15: save
//.........这里部分代码省略.........
$imageWidth = JRequest::getInt('itemImageS');
} else {
$imageWidth = $params->get('itemImageS', '200');
}
$handle->image_x = $imageWidth;
$handle->Process($savepath);
//XSmall image
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_convert = 'jpg';
$handle->jpeg_quality = $params->get('imagesQuality');
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $filename . '_XS';
if (JRequest::getInt('itemImageXS')) {
$imageWidth = JRequest::getInt('itemImageXS');
} else {
$imageWidth = $params->get('itemImageXS', '100');
}
$handle->image_x = $imageWidth;
$handle->Process($savepath);
//Generic image
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_convert = 'jpg';
$handle->jpeg_quality = $params->get('imagesQuality');
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $filename . '_Generic';
$imageWidth = $params->get('itemImageGeneric', '300');
$handle->image_x = $imageWidth;
$handle->Process($savepath);
if ($files['image']['error'] === 0) {
$handle->Clean();
}
} else {
$mainframe->redirect('index.php?option=com_k2&view=items', $handle->error, 'error');
}
}
if (JRequest::getBool('del_image')) {
$current =& JTable::getInstance('K2Item', 'Table');
$current->load($row->id);
$filename = md5("Image" . $current->id);
if (JFile::exists(JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'src' . DS . $filename . '.jpg')) {
JFile::delete(JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'src' . DS . $filename . '.jpg');
}
if (JFile::exists(JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . $filename . '_XS.jpg')) {
JFile::delete(JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . $filename . '_XS.jpg');
}
if (JFile::exists(JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . $filename . '_S.jpg')) {
JFile::delete(JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . $filename . '_S.jpg');
}
if (JFile::exists(JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . $filename . '_M.jpg')) {
JFile::delete(JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . $filename . '_M.jpg');
}
if (JFile::exists(JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . $filename . '_L.jpg')) {
JFile::delete(JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . $filename . '_L.jpg');
}
if (JFile::exists(JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . $filename . '_XL.jpg')) {
JFile::delete(JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . $filename . '_XL.jpg');
}
if (JFile::exists(JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . $filename . '_Generic.jpg')) {
JFile::delete(JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . $filename . '_Generic.jpg');
}
$row->image_caption = '';
$row->image_credits = '';