function thumb_one($path) { $handle = new upload($path); /********************** //Create coloured Thumbsnail **********************/ $handle->file_safe_name = false; $handle->file_overwrite = true; $handle->image_resize = true; $handle->image_ratio = true; $size = getimagesize($path); $factor = $size[0] / $size[1]; $to_be_cut = abs(round(($size[0] - $size[1]) / 2)); // determine how far we zoom in for making the thumbnail looking not streched if ($factor >= 1) { //picture horizontal $handle->image_y = 80; $handle->image_precrop = "0px " . $to_be_cut . "px"; } else { //picture vertical $handle->image_x = 80; $handle->image_precrop = $to_be_cut . "px 0px"; } $handle->process('/var/www/web360/html/felix/pics/thumbs/'); /**************************** //greyscale thumb (do rarely the same like before) *****************************/ $handle->file_safe_name = false; $handle->file_overwrite = true; $handle->image_resize = true; $handle->image_ratio = true; $handle->image_greyscale = true; //only difference // determine how far we zoom in for making the thumbnail looking not streched if ($factor >= 1) { //picture horizontal $handle->image_y = 80; $handle->image_precrop = "0px " . $to_be_cut . "px"; } else { //picture vertical $handle->image_x = 80; $handle->image_precrop = $to_be_cut . "px 0px"; } $handle->process('/var/www/web360/html/felix/pics/thumbs/bw/'); if (!$handle->processed) { die('error : ' . $handle->error); } }
public function beforeSave($options = array()) { if (is_numeric(key($this->data['Foto']))) { $produto_id = $this->data['Foto']['produto_id']; foreach ($this->data['Foto'] as $key => $foto) { if (is_numeric($key)) { if (!empty($foto['tmp_name'])) { App::uses('upload', 'Vendor'); $imagem = new upload($foto); if ($imagem->uploaded) { $imagem->resize = true; $imagem->imagem_x = 100; $imagem->imagem_ratio_y = true; $imagem->process('img/produtos/'); if ($imagem->processed) { $_foto = array('produto_id' => $produto_id, 'arquivo' => $imagem->file_dst_name); $this->create(); $this->save($_foto); } else { throw new Exception($imagem->error); } } else { throw new Exception($imagem->error); } } } } if (!isset($_foto)) { return false; } $this->data['Foto'] = $_foto; } }
public function handleMenuUpload() { $filename = $this->user->getMenuFile(); if (!empty($_FILES['input_menu']['tmp_name']) && is_uploaded_file($_FILES['input_menu']['tmp_name'])) { $validImageTypes = array("jpg", "jpeg", "png", "pdf"); if (filesize($_FILES['input_menu']['tmp_name']) > MAX_IMAGE_UPLOAD_FILESIZE) { echo "Upload is too big."; return false; } $menuUpload = new upload($_FILES['input_menu']); $menuUploadFolder = ASSETS_PATH . "downloads/"; $menuFileInfo = pathinfo($_FILES['input_menu']['name']); $newFilenameBase = $this->user->getStub() . "_menu"; $ext = strtolower(pathinfo($_FILES['input_menu']['name'], PATHINFO_EXTENSION)); if (!in_array($ext, $validImageTypes)) { echo "invalidImageType"; return false; } if ($menuUpload->uploaded) { ## Move uploaded file and resize $menuUpload->file_new_name_body = $newFilenameBase; $menuUpload->file_overwrite = true; $menuUpload->process($menuUploadFolder); if ($menuUpload->processed) { $filename = $newFilenameBase . "." . $ext; } else { echo $menuUpload->error; } } else { echo $menuUpload->error; } } return $filename; }
public function uploadFileImage($file, $ruta, $name) { if (isset($_FILES[$file]['name'])) { if ($_FILES[$file]['name']) { $upload = new upload($_FILES[$file], 'es_ES'); $upload->allowed = array('image/jpg', 'image/jpeg', 'image/png', 'image/gif'); $upload->file_max_size = '524288'; // 512KB if ($name) { $upload->file_new_name_body = 'upl_' . $name; } else { $upload->file_new_name_body = 'upl_' . sha1(uniqid()); } $upload->process($ruta); if ($upload->processed) { //THUMBNAILS $imagen = $upload->file_dst_name; $thumb = new upload($upload->file_dst_pathname); $thumb->image_resize = true; $thumb->image_x = 150; $thumb->image_y = 150; //$thumb->file_name_body_pre= 'thumb_'; $thumb->process($ruta . 'thumb' . DS); return true; } else { throw new Exception('Error al subir la imagen: ' . $upload->error); } } } else { return false; } }
/** * Uploads a new file for the given FileField instance. * * @param string $name EAV attribute name * @throws \Cake\Network\Exception\NotFoundException When invalid slug is given, * or when upload process could not be completed */ public function upload($name) { $instance = $this->_getInstance($name); require_once Plugin::classPath('Field') . 'Lib/class.upload.php'; $uploader = new \upload($this->request->data['Filedata']); if (!empty($instance->settings['extensions'])) { $exts = explode(',', $instance->settings['extensions']); $exts = array_map('trim', $exts); $exts = array_map('strtolower', $exts); if (!in_array(strtolower($uploader->file_src_name_ext), $exts)) { $this->_error(__d('field', 'Invalid file extension.'), 501); } } $response = ''; $uploader->file_overwrite = false; $folder = normalizePath(WWW_ROOT . "/files/{$instance->settings['upload_folder']}/"); $url = normalizePath("/files/{$instance->settings['upload_folder']}/", '/'); $uploader->process($folder); if ($uploader->processed) { $response = json_encode(['file_url' => Router::url($url . $uploader->file_dst_name, true), 'file_size' => FileToolbox::bytesToSize($uploader->file_src_size), 'file_name' => $uploader->file_dst_name, 'mime_icon' => FileToolbox::fileIcon($uploader->file_src_mime)]); } else { $this->_error(__d('field', 'File upload error, details: {0}', $uploader->error), 502); } $this->viewBuilder()->layout('ajax'); $this->title(__d('field', 'Upload File')); $this->set(compact('response')); }
public function updateImage() { require_once 'helpers/upload.php'; $code = ''; if (isset($_POST['id']) && isset($_POST['path'])) { $id = intval($_POST['id']); $handle = new upload($_FILES['image_field']); if ($handle->uploaded) { $handle->file_new_name_body = $id; $handle->image_resize = true; $handle->image_x = 100; $handle->image_ratio_y = true; $handle->file_overwrite = true; $handle->process($_SERVER['DOCUMENT_ROOT'] . '/EduDB/imageUploads/'); if ($handle->processed) { $handle->clean(); } else { $_SESSION['ERROR'] = $handle->error; // Failure } } Identity::updateImage($id, '/EduDB/imageUploads/' . $handle->file_dst_name); } header("Location: " . $_POST['path']); }
public function nuevo() { //verifica el rol y los permisos de usuario. $this->_acl->acceso('nuevo_post'); //asigna titulo a la vista $this->_view->assign('titulo', 'Nuevo Post'); //coloca el archivos js y js.validate. $this->_view->setJsPlugin(array('jquery.validate')); $this->_view->setJs(array('nuevo')); //si el archivo fue mandado entonces se asignan los valores de $_POST a la variable datos. if ($this->getInt('guardar') == 1) { $this->_view->assign('datos', $_POST); //verifica si el post tiene titulo if (!$this->getTexto('titulo')) { $this->_view->assign('_error', 'Debe introducir el titulo del post'); $this->_view->renderizar('nuevo', 'post'); exit; } //verifica si el post tiene cuerpo if (!$this->getTexto('cuerpo')) { $this->_view->assign('_error', 'Debe introducir el cuerpo del post'); $this->_view->renderizar('nuevo', 'post'); exit; } $imagen = ''; //verifica si se ha seleccionado un archivo tipo imagen if ($_FILES['imagen']['name']) { //se define la ruta de la imagen $ruta = ROOT . 'public' . DS . 'img' . DS . 'post' . DS; //Se crea un objeto upload con idioma español. $upload = new upload($_FILES['imagen'], 'es_Es'); //se especifica el tipo de archivo. $upload->allowed = array('image/*'); //se define un nombre para el archivo. $upload->file_new_name_body = 'upl_' . uniqid(); //Se inicia la carga con la ruta destino especificada $upload->process($ruta); //si se ha logrado la carga entonces crear una miniatura con upload libreria. if ($upload->processed) { $imagen = $upload->file_dst_name; $thumb = new upload($upload->file_dst_pathname); $thumb->image_resize = true; $thumb->image_x = 100; $thumb->image_y = 70; $thumb->file_name_body_pre = 'thumb_'; $thumb->process($ruta . 'thumb' . DS); } else { $this->_view->assign('_error', $upload->error); $this->_view->renderizar('nuevo', 'post'); exit; } } //Luego de guardarse la imagen entonces se guarda el post $this->_post->insertarPost($this->getPostParam('titulo'), $this->getPostParam('cuerpo'), $imagen); //Se redicciona al index de post. $this->redireccionar('post'); } //Se renderiza nuevamente la vista nuevo del post. $this->_view->renderizar('nuevo', 'post'); }
public function nuevo() { $this->_acl->acceso('Administrador'); $this->_view->assign('titulo', 'Nueva Aplicación'); $this->_view->assign('tipo_app', $this->_aplicacion->getTipoApp()); $this->_view->setJs(array('app')); if ($this->getInt('guardar') == 1) { $this->_view->assign('datos', $_POST); if (!$this->getTexto('nombre')) { $this->_view->assign('_error', 'Debe introducir nombre'); $this->_view->renderizar('nuevo', 'aplicaciones'); exit; } if (!$this->getTexto('descp')) { $this->_view->assign('_error', 'Debe introducir una descripción'); $this->_view->renderizar('nuevo', 'aplicaciones'); exit; } //Agregar demás verificaciones $imagen = ''; if (isset($_FILES['imagen']['name'])) { $this->getLibrary('upload' . DS . 'class.upload'); $ruta = ROOT . 'public' . DS . 'img' . DS . 'apps' . DS; $upload = new upload($_FILES['imagen'], 'es_Es'); $upload->allowed = array('image/*'); $upload->file_new_name_body = 'upl_' . uniqid(); $upload->process($ruta); if ($upload->processed) { $imagen = $upload->file_dst_name; $thumb = new upload($upload->file_dst_pathname); $thumb->image_resize = true; $thumb->image_x = 100; $thumb->image_y = 70; $thumb->file_name_body_pre = 'thumb_'; $thumb->process($ruta . 'thumb' . DS); } else { $this->_view->assign('_error', $upload->error); $this->_view->renderizar('nuevo', 'aplicaciones'); exit; } } if ($this->_aplicacion->crearApp($_POST['nombre'], $_POST['descp'], $imagen, $_POST['url'], $_POST['host'], $_POST['usu'], $_POST['clave'], $_POST['nom_bd'], $_POST['puerto'], $_POST['tipo'])) { $this->_view->assign('datos', false); $this->_view->assign('_confirmacion', 'Conexión exitosa'); $this->_view->renderizar('nuevo', 'aplicaciones'); exit; } else { $this->_view->assign('_confirmacion', 'No se realizo la conexión, verifique los datos'); $this->_view->renderizar('nuevo', 'aplicaciones'); exit; } } $this->_view->renderizar('nuevo', 'aplicaciones'); exit; }
public function makeThumb() { Yii::import('ext.image.class_upload.upload'); $handle = new upload('.'.$this->imgPath.$this->image_name); $handle->image_resize = true; $handle->image_ratio_crop = 'T'; $handle->image_x = 72; $handle->image_y = 72; $handle->process('.'.$this->thumbPath); }
public function saveAction() { $cid = intval($_POST['wid']); $name = $_POST['name_cn']; $name_en = $_POST['name_en']; $type = $_POST['type']; $price = $_POST['price']; $desc = $_POST['desc']; $year = $_POST['years']; $active = isset($_POST['active']) && $_POST['active'] == 'on' ? 1 : 0; if ($cid) { $sql = "Update \n\t\t\t\t\t\t\t`product` \n\t\t\t\t\t\tset \n\t\t\t\t\t\t\t`name_cn`='" . ms($name) . "',\n\t\t\t\t\t\t\t`name_en`='" . ms($name_en) . "',\n\t\t\t\t\t\t\t`price`='" . intval($price) . "',\n\t\t\t\t\t\t\t`years`=" . intval($year) . ",\n\t\t\t\t\t\t\t`desc`='" . ms($desc) . "',\n\t\t\t\t\t\t\t`type`=" . intval($type) . ",\n\t\t\t\t\t\t\t`active`=" . intval($active) . ",\n\t\t\t\t\t\t\t`modify_time`=" . time() . " \n\t\t\t\t\t\twhere \n\t\t\t\t\t\t\t`id`=" . ms($cid); } else { $sql = "Insert into\n\t\t\t\t\t\t\t `product` (\n\t\t\t\t\t\t\t \t\t`name_cn`,\n\t\t\t\t\t\t\t \t\t`name_en`,\n\t\t\t\t\t\t\t \t\t`price`,\n\t\t\t\t\t\t\t \t\t`years`,\n\t\t\t\t\t\t\t \t\t`desc`,\n\t\t\t\t\t\t\t \t\t`type`,\n\t\t\t\t\t\t\t \t\t`active`,\n\t\t\t\t\t\t\t \t\t`modify_time`) \n\t\t\t\t\t\tValues(\n\t\t\t\t\t\t\t'" . ms($name) . "',\n\t\t\t\t\t\t\t'" . ms($name_en) . "',\n\t\t\t\t\t\t\t'" . ms($price) . "',\n\t\t\t\t\t\t\t'" . ms($year) . "',\n\t\t\t\t\t\t\t'" . ms($desc) . "',\n\t\t\t\t\t\t\t'" . ms($type) . "',\n\t\t\t\t\t\t\t'" . ms($active) . "',\n\t\t\t\t\t\t\t" . time() . "\n\t\t\t\t\t\t)"; } if (DB::query($sql) && !$cid) { $b_id = DB::lastInsertID(); } else { if (DB::query($sql) && $cid) { $b_id = $cid; } } if (!empty($_FILES)) { $order = 1; foreach ($_FILES as $i => $v) { if (!$v['error']) { $handle1 = new upload($v); if ($handle1->uploaded) { $handle1->file_name_body_pre = '16du_'; $handle1->file_new_name_body = $b_id . '_' . $order; //$handle1->file_new_name_ext = 'png'; $handle1->file_overwrite = true; $handle1->file_max_size = '40480000'; // $handle1->image_convert = 'png'; //$handle1->png_compression = 5; $handle1->process(PRODUCT_SRC . $b_id . '/'); if ($handle1->processed) { $sql = "Update `product` set `src" . $order . "` = '" . $handle1->file_dst_name . "' where `id`=" . $b_id; DB::query($sql); $handle1->clean(); } else { //echo 'error : ' . $handle1->error; } $order++; } } } } $res = new ResultObj(true, '', '保存成功'); echo $res->toJson(); exit; }
function edit() { $image = clear($_POST['image']); if ($_FILES['file']['name']) { if ($_POST['image']) { unlink($this->pathadm . $_POST['image']); unlink($this->pathadm . 'resize/' . $_POST['image']); } $upload = new upload(); $upload->process($_FILES['file'], $this->pathadm, $this->max_width); $image = clear($upload->name); } $input = array('name' => clear($_POST['name']), 'alias' => clear($_POST['alias']), 'cha_id' => intval($_POST['cha']), 'cat_id' => intval($_POST['cat']), 'special' => intval($_POST['special']), 'description' => clear($_POST['description']), 'detail' => clear($_POST['detail']), 'image' => $image, 'cards_list' => @implode(',', $_POST['cards']), 'ordering' => (int) $ordering, 'card_slogan' => clear($_POST['card_slogan'])); $this->db->update_record($this->table, $input, $this->key . '=' . $_GET['id']); security::redirect($this->module, 'list'); }
public function modificar() { if (strtolower($this->getServer('HTTP_X_REQUESTED_WITH')) == 'xmlhttprequest' || Session::get('sess_browser') == 'IE9') { $rutaIMG = ROOT . 'public' . DS . 'img' . DS . 'voucher' . DS; $MLV_agencia = $this->loadModel('agencia'); //echo var_dump($_POST); //echo '<br>';echo '<br>';echo '<br>'; //echo var_dump($_FILES); exit; if (isset($_FILES['flImagenVouAgen']['name'])) { if ($_FILES['flImagenVouAgen']['name']) { //$this->getLibrary('upload' . DS . 'class.upload'); $upload = new upload($_FILES['flImagenVouAgen'], 'es_ES'); $upload->allowed = array('image/jpg', 'image/jpeg', 'image/png', 'image/gif'); $upload->file_max_size = '524288'; // 512KB //$upload->file_new_name_body= 'upl_' . uniqid(); $upload->file_new_name_body = 'upl_' . Session::get('sessMOD_LV_idAgen'); $upload->process($rutaIMG); if ($upload->processed) { $MLV_agencia->actualizaVoucherAgen(Session::get('sessMOD_LV_idAgen'), $upload->file_dst_name); echo 'OK'; } else { throw new Exception($upload->error); } } else { throw new Exception('Debe seleccionar un archivo desde su computador...'); } } else { if ($this->getTexto('chk_flImagenVouAgen')) { if ($this->getTexto('chk_flImagenVouAgen') == 'on') { if (Functions::eliminaFile($rutaIMG . Session::get('sessMOD_LV_imagen'))) { $MLV_agencia->actualizaVoucherAgen(Session::get('sessMOD_LV_idAgen'), ''); echo 'OK'; } else { throw new Exception('Error al eliminar el archivo, intente nuevamente'); } } else { throw new Exception('Debe seleccionar un archivo a eliminar'); } } else { throw new Exception('Debe seleccionar un archivo desde su computador'); } } } else { throw new Exception('Error inesperado, intente nuevamente. Si el error persiste comuniquese con el administrador'); } }
function edit() { $image = clear($_POST['image']); if ($_FILES['file1']['name']) { if ($_POST['image']) { unlink($this->pathadm . $_POST['image']); unlink($this->pathadm . 'resize/' . $_POST['image']); } $upload1 = new upload(); $upload1->process($_FILES['file1'], $this->pathadm, $this->max_width); $image = clear($upload1->name); } //var_dump($image); exit; $input = array('name' => clear($_POST['name']), 'alias' => clear($_POST['alias']), 'head_name' => clear($_POST['head_name']), 'top_list' => $toplist, 'top_type_name' => $topname, 'icon_on' => intval($_POST['iconchk']), 'header_text' => clear($_POST['header_text']), 'footer_text' => clear($_POST['footer_text']), 'ordering' => intval($_POST['ordering']), 'status' => intval($_POST['status']), 'cards_list' => implode(',', $_POST['cards']), 'sapxep' => implode(',', $_POST['sapxep']), 'title' => clear($_POST['title']), 'keyword' => clear($_POST['keyword']), 'destination' => clear($_POST['destination']), 'assign_banner' => clear($_POST['assign_banner']), 'banner' => intval($_POST['banner']), 'featured' => intval($_POST['featured']), 'image' => $image, 'card_slogan' => clear($_POST['card_slogan'])); $this->db->update_record($this->table, $input, $this->key . '=' . intval($_GET['id'])); security::redirect($this->module, 'list_qualitys'); }
public function nuevo() { $this->_acl->acceso('nuevo_post'); $this->_view->assign('titulo', 'Nuevo Post'); $this->_view->setJsPlugin(array('jquery.validate')); $this->_view->setJs(array('nuevo')); if ($this->getInt('guardar') == 1) { $this->_view->assign('datos', $_POST); if (!$this->getTexto('titulo')) { $this->_view->assign('_error', 'Debe introducir el titulo del post'); $this->_view->renderizar('nuevo', 'post'); exit; } if (!$this->getTexto('cuerpo')) { $this->_view->assign('_error', 'Debe introducir el cuerpo del post'); $this->_view->renderizar('nuevo', 'post'); exit; } $imagen = ''; if ($_FILES['imagen']['name']) { $ruta = ROOT . 'public' . DS . 'img' . DS . 'post' . DS; $upload = new upload($_FILES['imagen'], 'es_Es'); $upload->allowed = array('image/*'); $upload->file_new_name_body = 'upl_' . uniqid(); $upload->process($ruta); if ($upload->processed) { $imagen = $upload->file_dst_name; $thumb = new upload($upload->file_dst_pathname); $thumb->image_resize = true; $thumb->image_x = 100; $thumb->image_y = 70; $thumb->file_name_body_pre = 'thumb_'; $thumb->process($ruta . 'thumb' . DS); } else { $this->_view->assign('_error', $upload->error); $this->_view->renderizar('nuevo', 'post'); exit; } } $this->_post->insertarPost($this->getPostParam('titulo'), $this->getPostParam('cuerpo'), $imagen); $this->redireccionar('post'); } $this->_view->renderizar('nuevo', 'post'); }
public function editarAction() { $this->view->setFile('editar'); $user_id = $this->auth->getUserId(); $this->request->setCustomFilters(array('email' => FILTER_VALIDATE_EMAIL)); $post = $this->request->post(); if (!empty($post)) { $atualizarUsuario = User::atualizar($user_id, $post); if ($atualizarUsuario->status === false) { $this->load('Helpers\\Alert', array('danger', 'Ops! Não foi possível atualizar seu perfil. <br> Verifique os erros abaixo:', $atualizarUsuario->errors)); } else { if (isset($_FILES['image']) && !empty($_FILES['image']['tmp_name'])) { $uploadUserImage = new upload($_FILES['image']); if ($uploadUserImage->uploaded) { $image_name = md5(uniqid()); $uploadUserImage->file_new_name_body = $image_name; $uploadUserImage->file_new_name_ext = 'png'; $uploadUserImage->resize = true; $uploadUserImage->image_x = 500; $uploadUserImage->image_ratio_y = true; $dir_path = ROOT_PATH . DS . 'public' . DS . 'uploads' . DS . 'users' . DS . $atualizarUsuario->user->id . DS; $uploadUserImage->process($dir_path); if ($uploadUserImage->processed) { $uploadUserImage->clean(); $this->load('Helpers\\Alert', array('success', 'Uhuul! Perfil atualizado com sucesso!')); if (!is_null($atualizarUsuario->user->image)) { unlink($dir_path . $atualizarUsuario->user->image); } $atualizarUsuario->user->image = $image_name . '.png'; $atualizarUsuario->user->save(false); } else { $this->load('Helpers\\Alert', array('error', 'Oops! Não foi possível atualizar a sua imagem de perfil', $uploadUserImage->error)); } } } else { $this->load('Helpers\\Alert', array('success', 'Uhuul! Perfil atualizado com sucesso!')); } $this->view->setVar('user', $atualizarUsuario->user); } } }
public function newContact() { $identity = array('fName' => $_POST['firstName'], 'mName' => $_POST['middleName'], 'lName' => $_POST['lastName'], 'gender' => $_POST['gender'], 'email' => $_POST['email'], 'type' => 2); $contactIdentityId = Identity::newIdentity($identity); if (!$contactIdentityId) { $_SESSION['Error'] = "Unable to create a Contact Identity!"; header("Location: " . $_POST['path']); // TODO: This should go to an error page. return false; } require_once 'helpers/upload.php'; $code = ''; if ($contactIdentityId) { $id = intval($contactIdentityId); $handle = new upload($_FILES['image_field']); if ($handle->uploaded) { $handle->file_new_name_body = $id; $handle->image_resize = true; $handle->image_x = 100; $handle->image_ratio_y = true; $handle->file_overwrite = true; $handle->process($_SERVER['DOCUMENT_ROOT'] . '/EduDB/imageUploads/'); if ($handle->processed) { $handle->clean(); } else { $_SESSION['ERROR'] = $handle->error; // Failure } } Identity::updateImage($id, '/EduDB/imageUploads/' . $handle->file_dst_name); } // If we get here then we have made an identity but have not linked it // to the target contact yet. We will need to set the relationship. if (!session_id()) { session_start(); } $_SESSION['contact']['studentId'] = $_POST['studentId']; $_SESSION['contact']['studentIdentityId'] = $_POST['identityId']; $_SESSION['contact']['contactIdentityId'] = $contactIdentityId; header("Location: ?controller=contact&action=setRelationship"); }
public function beforeSave($options = array()) { if (!empty($this->data['Banner']['arquivo']['tmp_name'])) { App::uses('upload', 'Vendor'); $imagem = new upload($this->data['Banner']['arquivo']); if ($imagem->uploaded) { $imagem->process('img/banners/'); if ($imagem->processed) { $this->data['Banner']['arquivo'] = $imagem->file_dst_name; } else { throw new Exception($imagem->error); } } else { throw new Exception($imagem->error); } } elseif (isset($this->data['Banner']['id'])) { $banner = $this->findById($this->data['Banner']['id']); $this->data['Banner']['arquivo'] = $banner['Banner']['arquivo']; } else { throw new Exception('Nenhum arquivo foi enviado!'); } }
function edit() { $image = clear($_POST['image']); if ($_FILES['file1']['name']) { if ($_POST['image']) { unlink($this->pathadm . $_POST['image']); unlink($this->pathadm . 'resize/' . $_POST['image']); } $upload1 = new upload(); $upload1->process($_FILES['file1'], $this->pathadm, $this->max_width); $image = clear($upload1->name); } $result = $this->db->query("SELECT tbl_id,alias FROM 8x_cards_bank WHERE tbl_id='" . (int) $_POST['assign_bank'] . "' LIMIT 1 "); $rowdata = $this->db->fetch_assoc($result); //var_dump($image); exit; if (isset($rowdata['tbl_id']) && $rowdata['tbl_id']) { $alias = isset($rowdata['alias']) ? $rowdata['alias'] : ""; $input = array('tbl_id' => $rowdata['tbl_id'], 'name' => clear($_POST['name']), 'alias' => clear($alias), 'destination' => clear($_POST['destination']), 'ordering' => intval($_POST['ordering']), 'status' => intval($_POST['status']), 'image' => $image); $this->db->update_record($this->table, $input, $this->key . '=' . intval($_GET['id'])); } security::redirect($this->module, 'list_issuers'); }
function __convertImages() { $images = $this->TeamsObject->Team->PersonalImage->find('all', array('fields' => array('filename'), 'conditions' => array('model' => 'Team', 'prop' => 'Personal'))); App::import('Vendor', 'example', array('file' => 'class.upload.php')); $this->settings['baseDir'] = WWW_ROOT . 'img' . DS . 'Team' . DS; $this->settings['thumbsDir'] = WWW_ROOT . 'img' . DS . 'Team' . DS . 'thumbs' . DS; if ($handle1 = opendir($this->settings['baseDir'])) { while (false !== ($file = readdir($handle1))) { $handle = new upload($this->settings['baseDir'] . $file); if ($handle->uploaded) { // $image['PersonalImage']['filename'] = str_replace('.jpg','',$image['PersonalImage']['filename']); //$image['PersonalImage']['filename'] = str_replace('.gif','',$image['PersonalImage']['filename']); //$image['PersonalImage']['filename'] = str_replace('.png','',$image['PersonalImage']['filename']); //$handle->file_new_name_body = $image['PersonalImage']['filename']; $handle->image_resize = true; //$handle->image_ratio_crop = true; $handle->image_resize = true; $handle->image_x = 120; $handle->image_ratio_y = true; //$handle->image_x = 120; //$handle->image_y = 120; //$handle->image_ratio_fill = 'C'; $handle->process($this->settings['thumbsDir']); if ($handle->processed) { echo 'image resized<br>'; $handle->clean(); } else { echo 'error : ' . $handle->error . '<br>'; } } else { echo $this->settings['baseDir'] . $file . " is not uploaded<br>"; } } closedir($handle1); } exit; }
if (empty($error)) { mysql_query("UPDATE `animes` SET\n `refid` = '{$cat}',\n `name` = '" . mysql_real_escape_string($name) . "',\n `text` = '" . mysql_real_escape_string($text) . "',\n `user_id` = '" . $user_id . "',\n `time` = '" . $time . "' WHERE `id`='{$id}'"); //$img_id = mysql_insert_id(); require_once '../incfiles/lib/class.upload.php'; $handle = new upload($_FILES['imagefile']); if ($handle->uploaded) { // Обрабатываем фото $handle->file_new_name_body = 'icon_' . $id; $handle->allowed = array('image/jpeg', 'image/jpg', 'image/gif', 'image/png'); $handle->file_max_size = 1024 * $set['flsz']; $handle->file_overwrite = true; $handle->image_resize = true; $handle->image_x = 100; $handle->image_ratio_y = true; $handle->image_convert = 'jpg'; $handle->process('../files/blogs/'); if ($handle->processed) { @chmod('../files/blogs/icon_' . $id . '.jpg', 0666); } $handle->file_new_name_body = 'anime_icon_' . $id; $handle->allowed = array('image/jpeg', 'image/jpg', 'image/gif', 'image/png'); $handle->file_max_size = 1024 * $set['flsz']; $handle->file_overwrite = true; $handle->image_resize = true; $handle->image_x = 32; $handle->image_y = 32; $handle->image_convert = 'jpg'; $handle->process('../files/blogs/'); if ($handle->processed) { @chmod('../files/blogs/anime_icon_' . $id . '.jpg', 0666); }
function updateOtherDetails($db, $ua_sess, $post_vars, $file) { $arr = array('fname', 'lname', 'profile', 'dob', 'gender'); foreach ($arr as $value) { $data[$value] = $post_vars[$value]; } if (!empty($file)) { $Fupload = new upload($file['photo']); if ($Fupload->uploaded) { $Fupload->file_new_name_body = $post_var_ins['randid']; $Fupload->image_resize = true; $Fupload->image_x = 100; $Fupload->image_ratio_y = true; $Fupload->file_overwrite = true; $Fupload->allowed = array('image/*'); $Fupload->process(IMG_DIR); if ($Fupload->processed) { $data['photo'] = $Fupload->file_dst_name; } else { if ($ua_sess['photo'] == 'm.png' || $ua_sess['photo'] == 'f.png') { $data['photo'] = $post_vars['gender'] . ".png"; } } } else { if ($ua_sess['photo'] == 'm.png' || $ua_sess['photo'] == 'f.png') { $data['photo'] = $post_vars['gender'] . ".png"; } } } else { if ($ua_sess['photo'] == 'm.png' || $ua_sess['photo'] == 'f.png') { $data['photo'] = $post_vars['gender'] . ".png"; } } if ($db->query_update(UA_TABLE, $data, "`randid`='" . $ua_sess['randid'] . "'")) { return true; } else { return false; } }
public function subir_foto($id) { //VALIDAR QUE ESTE LOGUEADO EL USUARIO if (Session::Get('autenticado_adminsciocco') == true) { Session::set('modulo', "admin"); if (!$this->filtrarInt($id)) { //Se redirecciona al index $this->redireccionar('index', 'items'); } //Si no existe un registro con ese id if (!$this->_items->getproducto($this->filtrarInt($id))) { //Se redirecciona al index $this->redireccionar('index', 'items'); } /* VALIDACION */ if ($this->getInt('guardar') == 1) { if ($_FILES['archivo']['name'] != "") { //Ruta donde se va a guardar el archivo $ruta = 'views/items/fotos' . DS . 'grande' . DS; $ruta1 = 'views/items/fotos' . DS; // echo $ruta; exit; //Se instancia la libreria $upload = new upload($_FILES['archivo'], 'es_Es'); /* Extensiones permitidas */ $upload->allowed = array('image/jpeg', 'image/png'); $nombre = Hash::getHash('sha1', $_FILES['archivo']['name'], HASH_KEY); /* Renombrando */ $upload->file_new_name_body = $nombre; /* extencion */ $upload->file_new_name_ext = 'jpg'; //Se evita que se auto-renombre $upload->file_auto_rename = false; //Se sobrescribe el archivo $upload->file_overwrite = true; //habilita redimesion de imagenes $upload->image_resize = true; //Crop de la imagen $upload->image_ratio = true; $upload->image_x = 300; $upload->image_y = 250; /* Se llama metodo para indicar ruta donde se guarda el archivo */ $upload->process($ruta); /* Se verifica si ha sido exitoso */ if ($upload->processed) { /* Extensiones permitidas */ $upload->allowed = array('image/jpeg', 'image/png'); /* Renombrando */ $nombre = Hash::getHash('sha1', $_FILES['archivo']['name'], HASH_KEY); /* Renombrando */ $upload->file_new_name_body = $nombre; /* extencion */ $upload->file_new_name_ext = 'jpg'; //Se evita que se auto-renombre $upload->file_auto_rename = false; //Se sobrescribe el archivo $upload->file_overwrite = true; //habilita redimesion de imagenes $upload->image_resize = true; //Crop de la imagen $upload->image_ratio = false; $upload->image_x = 150; $upload->image_y = 125; $upload->process($ruta1); $this->_items->foto_item_nueva($this->filtrarInt($id), $nombre, "jpg"); } else { //Si no cumple la validacion sale mensaje de error $this->_view->_error = $upload->error; //Vista de la pagina actual $this->_view->renderizar('foto', false, true); //Saca de la funcion principal exit; } $this->_view->_mensaje = 'Foto subida Correctamente'; } } //Se renderiza a la pagina actual $this->_view->renderizar('foto', false, true); } else { $this->redireccionar('admin'); } }
$handle->file_new_name_body = $newName; $handle->image_resize = true; $handle->image_x = 200; $handle->image_ratio_y = true; $handle->file_safe_name = false; $ext = pathinfo($_FILES['image']['name'], PATHINFO_EXTENSION); if ($ext == 'png') { $extensie = ".png"; } if ($ext == 'jpg') { $extensie = ".jpg"; } if ($ext == 'gif') { $extensie = ".gif"; } $handle->process('images/tours'); if ($handle->processed) { echo 'image resized'; $handle->clean(); } else { echo 'error : ' . $handle->error; } } if (empty($_FILES['image']['name'])) { $newName = $selectedTour['image']; } $user->updateTourData($_SESSION['username'], $_POST['name'], $_POST['price'], $_POST['description'], $_GET['id'], $newName . $extensie, $_POST['adults'], $_POST['disabled'], $_POST['children'], $_POST['aged']); header('Location: memberpage.php'); } } ?>
} if (empty($err)) { set_time_limit(0); if (file_exists($root . '/img/stock/' . $_POST['temp'] . '.jpg')) { unlink($root . '/img/stock/' . $_POST['temp'] . '.jpg'); } $handle = new upload($_FILES['image']); $handle->file_new_name_body = $_POST['temp']; $handle->image_convert = "jpg"; // $handle->image_resize = true; // $handle->image_ratio_x = true; // $handle->image_y = 360; // $handle->image_x = true; // $handle->jpeg_quality = 100; // $handle->image_unsharp = false; $handle->process($root . '/img/stock'); // $handle->clean(); //удаляем все записи из banners где event_id=0 and data_create< сегодняшняя дата-1 день //сначала удаляем фотки $sql_select_zero_banners_photo = 'SELECT * FROM banners WHERE event_id=0 AND data_create <= "' . date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 1, date("Y"))) . '"'; $db->query($sql_select_zero_banners_photo); if ($db->getCount() > 0) { $arr = $db->getArray(); foreach ($arr as $in => $value) { if (file_exists($root . '/img/stock/' . $value['md5_mictotime'] . '.jpg')) { unlink($root . '/img/stock/' . $value['md5_mictotime'] . '.jpg'); } } } $sql_delete_zero_records = 'DELETE FROM banners WHERE event_id=0 AND data_create <= "' . date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 1, date("Y"))) . '"';
$DirectoryString = implode("/", $CurrentDirectory); $RootDirectory = $FrontEndImageLocationRoot . "/" . $DirectoryString; if (!file_exists($RootDirectory)) { $PHPZevelop->Location("file-manager"); } // Upload if (isset($_FILES["image"]) && strlen($_FILES["image"]["name"]) > 0) { $Image = new upload($_FILES["image"]); if (isset($_POST["renameto"]) && strlen($_POST["renameto"]) > 0) { $NewName = explode(".", $_POST["renameto"]); $Image->file_overwrite = true; $Image->file_new_name_body = implode(".", array_slice($NewName, 0, count($NewName) - 1)); $Image->file_new_name_ext = implode(".", array_slice($NewName, count($NewName) - 1)); } if ($Image->uploaded) { $Image->process($FrontEndImageLocationRoot . str_replace("//", "/", "/" . $DirectoryString)); } else { print_r($Image); } } ?> <h2>File Manager <?php if (isset($_FILES["image"]) && strlen($_FILES["image"]["name"]) > 0) { echo "<input value='" . $FrontEndImageLocationRoot . str_replace("//", "/", "/" . $DirectoryString . "/") . $Image->file_new_name_body . "." . $Image->file_new_name_ext . "' style='padding: 5px; margin-left: 15px; margin-top: -5px;' />"; } ?> </h2> <div style="width: 50%;">
public function process($parameters) { $articleManager = new ArticleManager(); $userManager = new UserManager(); $validation = new Validation(); $this->checkUser(); $loggedUser = $userManager->returnUser(); //editor je pristupny iba pre admina a redaktorov if ($loggedUser['admin'] == 1 || $loggedUser['admin'] == 2) { $article = array('article_id' => '', 'title' => '', 'thumbnail_img' => '', 'content' => '', 'url' => '', 'category' => '', 'description' => '', 'key_words' => '', 'author' => ''); //ak je odoslany formular if ($_POST) { //ziskanie clanku z $_POST $keys = array('article_id', 'title', 'thumbnail_img', 'content', 'url', 'category', 'description', 'key_words', 'author', 'public'); $article = array_intersect_key($_POST, array_flip($keys)); //upload a spracovanie suboru $imageUpload = new upload($_FILES['image_field'], 'sk_SK'); //nastavenie ID noveho clanku if (empty($article['article_id'])) { $article['article_id'] = $articleManager->returnLastArticleId() + 1; } $targetDirectory = 'img/articles/' . $article['article_id'] . '/'; $filePath = $targetDirectory . 'thumbnail.png'; try { //vytvori novy adresar podla ID noveho clanku if (!file_exists($targetDirectory)) { mkdir($targetDirectory, '0777', true); } //ak bol obrazok nahraty if ($imageUpload->uploaded) { $imageUpload->allowed = array('image/*'); //povolene formaty $imageUpload->mime_check = true; //kontrola formatu zapnuta $imageUpload->file_new_name_body = 'thumbnail'; //novy nazov suboru $imageUpload->image_resize = true; //zmensenie $imageUpload->image_convert = 'png'; //konvertovanie na png $imageUpload->image_x = 120; //vysledna sirka 120px $imageUpload->image_ratio_y = true; //vyska: auto //zmazanie existujuceho nahladoveho obrazka if (file_exists($filePath)) { unlink($filePath); } $imageUpload->process($targetDirectory); //uloz vysledny obrazok //ak bol obrazok ulozeny if ($imageUpload->processed) { //uloz cestu k obrazku do '$article' $article['thumbnail_img'] = $filePath; $imageUpload->clean(); } else { throw new UserError($imageUpload->error); } } } catch (UserError $error) { $this->createMessage($error->getMessage(), 'warning'); } //ulozenie clanku do databazy try { //vytvorenie URL adresy z pola title $article['url'] = $validation->checkUrl($article['title']); //ulozenie clanku do databazy $articleManager->saveArticle($_POST['article_id'], $article); $this->createMessage('Článok bol úspešne uložený', 'success'); //presmeruj na clanok $this->redirect('clanky/' . $article['url']); } catch (UserError $error) { $this->createMessage($error->getMessage(), 'warning'); $this->redirect('editor'); } } //ak je zadana URL adresa clanku na jeho editaciu if (!empty($parameters[0])) { $loadedArticle = $articleManager->returnArticle($parameters[0]); if ($loadedArticle) { $article = $loadedArticle; } else { $this->createMessage('Článok sa nenašiel', 'warning'); $this->redirect('chyba'); } $this->data['article'] = $article; //hlavicka stranky $this->head = array('title' => 'Editor - ' . $article['title'], 'key_words' => 'coding.wz.sk - editor', 'description' => 'Editor článkov'); $this->view = 'editor'; } else { $article['author'] = $userManager->returnUser()['name']; $this->data['article'] = $article; //hlavicka stranky $this->head = array('title' => 'Editor - Nový článok', 'key_words' => 'coding.wz.sk - editor', 'description' => 'Editor článkov'); $this->view = 'editor'; } } }
//check if the file is uploaded and process the file if file is uploaded if (!file_exists($_FILES['talent_photo']['tmp_name']) || !is_uploaded_file($_FILES['talent_photo']['tmp_name'])) { // do nothing } else { //if photo is uploaded process the file with upload class // process Talent Photos Information edit form DB::insert('tams_talent_photos', array('talent_id' => $talent_id, 'photo_caption' => $photo_caption, 'created_by' => $created_by, 'created_on' => $created_on, 'last_modified_by' => $last_modified_by, 'last_modified_on' => $last_modified_on)); $photo_id = DB::insertId(); $photo_name .= $talent_id . "_" . $photo_id; $handle = new upload($_FILES['talent_photo']); if ($handle->uploaded) { $handle->file_new_name_body = $photo_name; $handle->allowed = array('image/*'); // $handle->file_overwrite = true; $handle->image_convert = 'jpg'; $handle->process('../uploads/talent_photos/'); if ($handle->processed) { // save uploaded file name and path in database table field logo_url /* if talent id is not empty update the database */ $update = DB::update('tams_talent_photos', array('photo_path' => '/talent/uploads/talent_photos/' . $photo_name . '.jpg'), "talent_photo_id=%s", $photo_id); echo 'Photo is uploaded and path select saved in database'; $handle->clean(); } else { echo 'error : ' . $handle->error; } // close handle processed } // close handle uploaded } // close file exist header('Location: index.php?route=modules/talent/edit_talent_profile&talent_id=' . $talent_id . '#photos');
public function actionUpload() { if (isset($_FILES['files']) && $_FILES['files']) { require Yii::app()->basePath . '/components/upload.class.php'; $handle = new upload($_FILES['files']); $img_arr = array(); $file_info = AFunction::generate_file_name('news'); $_filename = $file_info['name']; $_filepath = realpath(Yii::app()->getBasePath() . '/../uploads/') . "/" . $file_info['physical_path']; if ($handle->uploaded) { //check extension if (!in_array($handle->file_src_name_ext, array('gif', 'jpg', 'jpeg', 'pjpeg'))) { //$this->error->add('ERROR_UPLOAD', $this->language->getMsg('YOU_CAN_UPLOAD_WITH_FILE_EXTENSION_JPG_JPEG_PJPEG')); return false; } $handle->file_new_name_body = $_filename; $handle->process($_filepath); if ($handle->processed) { require Yii::app()->basePath . '/components/byte_converter.class.php'; $byte = new byte_converter(); $byte->set_limit("mb"); $img_arr['id'] = 0; $img_arr['image_title'] = $_filename; $img_arr['image_ext'] = $handle->file_src_name_ext; $img_arr['image_path'] = $file_info['physical_path']; $img_arr['image_mime_type'] = $handle->image_src_type; $img_arr['image_width'] = $handle->image_src_x; $img_arr['image_height'] = $handle->image_src_y; $img_arr['image_size'] = $handle->file_src_size; $modelImage = new AImages(); $modelImage->image_title = $img_arr['image_title']; $modelImage->image_ext = $img_arr['image_ext']; $modelImage->image_path = $img_arr['image_path']; $modelImage->image_mime_type = $img_arr['image_mime_type']; $modelImage->image_width = $img_arr['image_width']; $modelImage->image_height = $img_arr['image_height']; $modelImage->image_size = $img_arr['image_size']; if ($modelImage->save()) { $img_arr['id'] = $modelImage->id; } } //upload width thumbnail 110 $handle->file_new_name_body = $_filename . '_' . Yii::app()->params->width110; $handle->image_resize = true; $handle->image_x = Yii::app()->params->width110; $handle->image_ratio_y = true; $handle->process($_filepath); if ($handle->processed) { $handle->Clean(); } echo json_encode($img_arr); exit; } else { echo json_encode(array('Upload Fail !')); exit; } } else { echo json_encode(array('Can not upload file !')); exit; } }
//check if the file is uploaded and process the file if file is uploaded if (!file_exists($_FILES['uploadlogo']['tmp_name']) || !is_uploaded_file($_FILES['uploadlogo']['tmp_name'])) { echo '<h2> No Logo ploaded</h2>'; } else { echo '<h2> Logo was uploaded</h2>'; //if logo file is uploaded process the file with upload class $handle = new upload($_FILES['uploadlogo']); if ($handle->uploaded) { $handle->file_new_name_body = $client_id . '_logo'; $handle->image_resize = true; $handle->image_x = 100; $handle->image_ratio_y = true; $handle->allowed = array('image/*'); $handle->image_convert = 'jpg'; $handle->file_overwrite = true; $handle->process('../uploads/clients/'); if ($handle->processed) { // save uploaded file name and path in database table field logo_url $last_modified_by = $_SESSION['user_id']; $last_modified_on = getDateTime(NULL, "mySQL"); /* if client id is not empty update the database */ if ($client_id != "") { $update = DB::update('tams_clients', array('logo_url' => '/talent/uploads/clients/' . $client_id . '_logo.jpg', 'last_modified_by' => $last_modified_by, 'last_modified_on' => $last_modified_on), "client_id=%s", $client_id); } echo 'Logo file uploaded and path select saved in database'; $handle->clean(); } else { echo 'error : ' . $handle->error; } // close handle processed }
function upload_excel_file() { $excel_file = $_FILES['excel_file']; $this->directory = PATH . "Excel_File/"; if ($excel_file['name'] != "") { if ($excel_file["type"] == "application/vnd.ms-excel") { $excel_file_upload = new upload($excel_file); $excel_file_upload->file_overwrite = true; $excel_file_upload->file_new_name_body = "student_current_enroll"; $excel_file_upload->process($this->directory); //if ($image_upload->processed) { //$this->registered(); $this->template->setAlert("File was Successfully Uploaded!..", Template::ALERT_SUCCESS); $excel_file_upload->clean(); $filename = "../Excel_File/student_current_enroll.xls"; if (file_exists($filename)) { $this->template->assign('excel_file', 'true'); } /* inserting into database table */ $excel_data = new Spreadsheet_Excel_Reader('../Excel_File/student_current_enroll.xls'); for ($y = 2; $y <= $excel_data->rowCount(); $y++) { $student_id = $excel_data->val($y, A); $lastname = $excel_data->val($y, B); $firstname = $excel_data->val($y, C); $middle_initial = $excel_data->val($y, D); if ($this->registered_student_model->isValid($student_id, $lastname, $firstname) && $this->administrator_model->isValid($student_id, $lastname, $firstname)) { $this->registered_student_model->insert($student_id, $lastname, $firstname, $middle_initial); } } /* ------------------------------- */ } else { $this->template->setAlert("You can Upload a XLS file only!..", Template::ALERT_ERROR); } } }