当前位置: 首页>>代码示例>>PHP>>正文


PHP WideImage::loadFromUpload方法代码示例

本文整理汇总了PHP中WideImage::loadFromUpload方法的典型用法代码示例。如果您正苦于以下问题:PHP WideImage::loadFromUpload方法的具体用法?PHP WideImage::loadFromUpload怎么用?PHP WideImage::loadFromUpload使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WideImage的用法示例。


在下文中一共展示了WideImage::loadFromUpload方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: editar

 public static function editar()
 {
     $cracha = new Cracha();
     $cracha->selecionarPorId($_GET['id']);
     if (!empty($_POST)) {
         $nomeCracha = $_POST['nome'];
         $idParticipante = $_POST['idParticipante'];
         $funcao = $_POST['funcao'];
         if (!empty($_FILES["foto_cracha"]["name"])) {
             $nomeFoto = $idParticipante . '-' . Util::substituiCaracteres($nomeCracha) . '.' . pathinfo($_FILES['foto_cracha']['name'], PATHINFO_EXTENSION);
             $foto = WideImage::loadFromUpload('foto_cracha');
             $imagem = $foto->crop($_POST['foto_x'], $_POST['foto_y'], $_POST['foto_w'], $_POST['foto_h']);
             @unlink('../fotosParticipantes/' . $nomeFoto);
             $imagem->saveToFile('../fotosParticipantes/' . $nomeFoto);
             $cracha->foto = $nomeFoto;
         }
         $cracha->nome = $nomeCracha;
         $cracha->funcao = $funcao;
         $cracha->fk_participante = $idParticipante;
         $cracha->salvar();
         self::redirecionar(Configuracao::$baseUrl . 'cracha/listar' . Configuracao::$extensaoPadrao);
     }
     self::$variaveis = array('cracha' => $cracha);
     self::$corpo = "editar";
     self::renderizar(self::$viewController);
 }
开发者ID:GDGPVH,项目名称:sistemaEvento,代码行数:26,代码来源:CrachaController.php

示例2: addAction

 public function addAction()
 {
     $config = Config::getInstance();
     $config = $config->getConfig();
     $Cars = new Cars();
     $this->view->data = $Cars->getCategory();
     $model = $this->request->getPost('model');
     $marka = $this->request->getPost('marka_id');
     $opis = $this->request->getPost('opis');
     $zdjecie = $this->request->getFiles('zdjecie');
     if ($model == NULL && $marka == NULL && $opis == NULL && $zdjecie == NULL) {
         $this->view->display('add');
     } else {
         if ($model == NULL || $marka == NULL || $opis == NULL || $zdjecie == NULL) {
             echo "Uzupelnij wszystkie pola";
         } else {
             $podpis = date("Y-m-d G:i:s", time());
             $zdjecie = WideImage::loadFromUpload('zdjecie');
             $zdjecie->saveToFile($config['DOC_ROOT'] . $config['CUSTOM_IMG_DIR'] . $podpis . '.png');
             $Car = new Cars();
             $Car->saveCar($model, $marka, $opis, $podpis);
             header('location: ' . Url::getUrl('car', 'list', array('status' => 8)));
         }
     }
 }
开发者ID:Nefryt,项目名称:mvc-app,代码行数:25,代码来源:carController.php

示例3: handleUpload

 /**
  * Handle candidate photo uploads
  * 
  * @throws Exception when an error occurs
  * @return null
  */
 public function handleUpload()
 {
     $mimeTypes = array('image/jpeg', 'image/png');
     if (wp_verify_nonce($_POST['graphic_material_upload_photo_nonce'], 'graphic_material_upload_photo') && isset($_FILES['photo'])) {
         if (!$_FILES['photo']['error'] && in_array($_FILES['photo']['type'], $mimeTypes)) {
             $img = WideImage::loadFromUpload('photo');
             if ($img->getWidth() < $this->minWidth || $img->getHeight() < $this->minHeight) {
                 $this->error = "Atenção: a imagem deve ter no mínimo {$this->minWidth}x{$this->minHeight} pixels para garantir a qualidade da impressão. A imagem enviada possui {$img->getWidth()}x{$img->getHeight()} pixels. Por favor envie outra imagem maior.";
             } else {
                 delete_option('photo-position-' . $this->fileName);
                 $filePath = GRAPHIC_MATERIAL_DIR . $this->fileName;
                 // override uploaded image with resized version with dimensions close to minWidth and minHeight (300 dpi)
                 $img = $img->resize($this->minWidth, $this->minHeight, 'outside');
                 $img->saveToFile($filePath);
                 // generate low resolution image to send to the browser (75 dpi)
                 $lowRes = $img->resize($this->screenWidth, $this->screenHeight, 'outside');
                 $lowRes->saveToFile(GRAPHIC_MATERIAL_DIR . $this->screenFileName);
                 $this->loadImage();
                 $this->crop();
             }
         } else {
             if (!$_FILES['photo']['error'] && !in_array($_FILES['photo']['type'], $mimeTypes)) {
                 $this->error = "Tipo de arquivo inválido, o arquivo deve ser dos tipos .png ou .jpg";
             } else {
                 $this->error = $this->handleUploadError($_FILES['photo']['error']);
             }
         }
     }
 }
开发者ID:cabelotaina,项目名称:redelivre,代码行数:35,代码来源:CandidatePhoto.php

示例4: updateCar

 public function updateCar($new_model, $new_marka, $new_opis, $is_photo, $id)
 {
     $query = "SELECT * FROM samochody WHERE samochody_id=:id";
     $sth = $this->db->prepare($query);
     $sth->bindParam(':id', $id);
     $sth->execute();
     $car = $sth->fetch();
     if (empty($new_model)) {
         $model = $car['model'];
     } else {
         $model = $new_model;
     }
     if (empty($new_marka)) {
         $marka = $car['marka_id'];
     } else {
         $marka = $new_marka;
     }
     if (empty($new_opis)) {
         $opis = $car['opis'];
     } else {
         $opis = $new_opis;
     }
     if ($is_photo['error'] == 4) {
         $podpis = $car['podpis'];
     } else {
         $zdjecie = WideImage::loadFromUpload('zdjecie');
         $config = Config::getInstance();
         $config = $config->getConfig();
         $old_podpis = $config['IMG_DIR'] . $car['podpis'] . '.png';
         unlink($old_podpis);
         $podpis = date("Y-m-d G:i:s", time());
         $zdjecie->saveToFile($config['DOC_ROOT'] . $config['CUSTOM_IMG_DIR'] . $podpis . '.png');
     }
     $update_query = "UPDATE samochody SET marka_id=:marka, model=:model, opis=:opis, podpis=:podpis WHERE samochody_id=:id";
     $up = $this->db->prepare($update_query);
     $up->bindParam(':marka', $marka);
     $up->bindParam(':model', $model);
     $up->bindParam(':opis', $opis);
     $up->bindParam(':podpis', $podpis);
     $up->bindParam(':id', $id);
     $up->execute();
 }
开发者ID:Nefryt,项目名称:mvc-app,代码行数:42,代码来源:Cars.php

示例5: testInvalidImageUploadField

 /**
  * @expectedException WideImage_InvalidImageSourceException
  */
 function testInvalidImageUploadField()
 {
     WideImage::loadFromUpload('xyz');
 }
开发者ID:thaida,项目名称:CMS,代码行数:7,代码来源:WideImageTest.php

示例6: adesivar

 /**
  * [adesivar description]
  * @return [type] [description]
  */
 public static function adesivar($photo)
 {
     $option = self::getOption('adesive');
     // se um dia tiver mais de um adesivo é só enviar o $index pelo post
     $index = 0;
     $adesive_filename = self::getAdesiveFilename($index);
     if ($adesive_filename) {
         $adesivo = WideImage::load($adesive_filename);
         $uploaded = WideImage::loadFromUpload($photo);
         $uploaded = $uploaded->resize(250, null);
         $new = $uploaded->merge($adesivo, 'right', 'bottom');
         header('Content-disposition: attachment; filename=foto.jpg');
         header('Content-type: image/jpeg');
         $new->output('jpg', 100);
         die;
     }
 }
开发者ID:cabelotaina,项目名称:redelivre,代码行数:21,代码来源:vendor.php

示例7: ajaxCallbackForUpload

 private function ajaxCallbackForUpload()
 {
     $json['message'] = $this->executeFormValidation();
     if ($json['message']) {
         return $json;
     }
     // Recupera logo da empresa para marca d'agua
     if ($_POST['watermark']) {
         $watermark = WideImage::load(Config::read('path.template') . Config::read(SYSTEM . '.theme') . "/img/watermark.png");
     }
     // Carrega imagem para o servidor
     $image = WideImage::loadFromUpload("file");
     // Recupera extensão da imagem
     $extension = strtolower(strrchr($_FILES['file']['name'], "."));
     // Gera URL única para o arquivo
     $photoUrl = md5(uniqid(time())) . $extension;
     foreach (json_decode($_POST['thumbnails']) as $description => $thumbnail) {
         // Redimensiona a imagem
         $resized = $image->resize($thumbnail[0], $thumbnail[1], 'outside');
         // Corta no tamanho especifico
         $resized = $resized->crop('center', 'center', $thumbnail[0], $thumbnail[1]);
         // Verifica se a marca d'água deve ser inserida na imagem carregada
         if ($_POST['watermark']) {
             // A logomarca deve ser inserida com 1/3 do tamanho da foto
             $logoSize = round($thumbnail[0] / 3);
             $watermarkResized = $watermark->resize($logoSize);
             // Posiciona a marca d'água no canto inferior direito da foto
             $resized = $resized->merge($watermarkResized, "right - 10%", "bottom - 10%");
         }
         $fileToSave = Config::read('path.photos') . '/' . $_POST['album'] . '/' . $description . '-' . $photoUrl;
         // Grava arquivo no diretório
         $resized->saveToFile($fileToSave);
     }
     $data = new stdClass();
     $data->album = $_POST['album'];
     $data->url = $photoUrl;
     $data->vertical = (int) ($image->getWidth() < $image->getHeight());
     // Grava referência no banco de dados
     $data->id = $this->myModel->insert($data);
     if ($data->id) {
         // Atualiza lista de fotos
         $this->myView->data = new stdClass();
         $this->myView->data->photos[] = $data;
         $json['photos'] = $this->myView->createPhotosForm();
     } else {
         // Retorna mensagem de erro do Banco de Dados
         $message = $this->myModel->getMessage();
         $json['message'] = $message['text'];
     }
     return $json;
 }
开发者ID:sohflp,项目名称:Hooked,代码行数:51,代码来源:trait.PhotoController.php


注:本文中的WideImage::loadFromUpload方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。