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


PHP SimpleImage::resizeToWidth方法代码示例

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


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

示例1: imageProcess

function imageProcess($img_info)
{
    $file = $img_info['img_upload_url_temp'] . $img_info['img'];
    $sizeInfo = getimagesize($file);
    if (is_array($sizeInfo)) {
        include_once 'libraries/SimpleImage.php';
        $image = new SimpleImage();
        $image->load($file);
        $width = $sizeInfo[0];
        $height = $sizeInfo[1];
        //img thumb
        $img_thumb = $img_info['img_upload_url_thumb'] . $img_info['img'];
        if ($width <= IMAGE_THUMB_WIDTH && $height <= IMAGE_THUMB_HEIGHT) {
            copy($file, $img_thumb);
        } elseif ($width >= $height) {
            $image->resizeToWidth(IMAGE_THUMB_WIDTH);
            $image->save($img_thumb);
        } elseif ($width < $height) {
            $image->resizeToHeight(IMAGE_THUMB_HEIGHT);
            $image->save($img_thumb);
        }
        //img
        $img = $img_info['img_upload_url'] . $img_info['img'];
        if ($img_info['original'] == 1) {
            $image->load($file);
            if ($width >= $height && $width > IMAGE_MAX_WIDTH) {
                $image->resizeToWidth(IMAGE_MAX_WIDTH);
                $image->save($img);
            } elseif ($width <= $height && $height > IMAGE_MAX_HEIGHT) {
                $image->resizeToHeight(IMAGE_MAX_HEIGHT);
                $image->save($img);
            } else {
                copy($file, $img);
            }
            if (file_exists($file)) {
                unlink($file);
            }
        } else {
            if (copy($file, $img)) {
                if (file_exists($file)) {
                    unlink($file);
                }
            }
        }
        return true;
    } else {
        return false;
    }
}
开发者ID:hieunhan1,项目名称:all-website-v5,代码行数:49,代码来源:controlUpload.php

示例2: actionUpload

 /**
  * 上传图片
  */
 public function actionUpload()
 {
     $fn = $_GET['CKEditorFuncNum'];
     $url = WaveCommon::getCompleteUrl();
     $imgTypeArr = WaveCommon::getImageTypes();
     if (!in_array($_FILES['upload']['type'], $imgTypeArr)) {
         echo '<script type="text/javascript">
             window.parent.CKEDITOR.tools.callFunction("' . $fn . '","","图片格式错误!");
             </script>';
     } else {
         $projectPath = Wave::app()->projectPath;
         $uploadPath = $projectPath . 'data/uploadfile/substance';
         if (!is_dir($uploadPath)) {
             mkdir($uploadPath, 0777);
         }
         $ym = WaveCommon::getYearMonth();
         $uploadPath .= '/' . $ym;
         if (!is_dir($uploadPath)) {
             mkdir($uploadPath, 0777);
         }
         $imgType = strtolower(substr(strrchr($_FILES['upload']['name'], '.'), 1));
         $imageName = time() . '_' . rand() . '.' . $imgType;
         $file_abso = $url . '/data/uploadfile/substance/' . $ym . '/' . $imageName;
         $SimpleImage = new SimpleImage();
         $SimpleImage->load($_FILES['upload']['tmp_name']);
         $SimpleImage->resizeToWidth(800);
         $SimpleImage->save($uploadPath . '/' . $imageName);
         echo '<script type="text/javascript">
             window.parent.CKEDITOR.tools.callFunction("' . $fn . '","' . $file_abso . '","上传成功");
             </script>';
     }
 }
开发者ID:xpmozong,项目名称:wavephp2_demos,代码行数:35,代码来源:SubstanceController.php

示例3: uploadFile

 protected function uploadFile()
 {
     if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $this->path)) {
         $path = $this->path;
         if (!$this->db->query("INSERT photo (name,folder,time,status) \n\t\t\tVALUES ('" . $this->name . "','" . $this->folder . "','" . time() . "','temp')")) {
             die("error");
         }
         $id = $this->db->getLastId();
         $this->image->load($path);
         $full = new SimpleImage();
         $full->load($path);
         if ($full->getWidth() > 1200) {
             $full->resizeToWidth(1200);
         }
         $full->save(str_replace('.', '.full.', $path));
         if ($this->image->getWidth() > 600) {
             $this->image->resizeToWidth(600);
         }
         $this->image->save($path);
         $size = $this->f->getFullSize($path, 90, 90);
         $img = array('name' => $this->name, 'path' => $path, 'count' => $this->getNum(), 'width' => $size['width'], 'height' => $size['height'], 'id' => $id);
         echo json_encode($img);
     } else {
         echo "error";
     }
 }
开发者ID:Sywooch,项目名称:dump,代码行数:26,代码来源:upload.php

示例4: upload_imagem_unica

function upload_imagem_unica($pasta_upload, $novo_tamanho_imagem, $novo_tamanho_imagem_miniatura, $host_retorno, $upload_miniatura)
{
    // data atual
    $data_atual = data_atual();
    // array com fotos
    $fotos = $_FILES['foto'];
    // extensoes de imagens disponiveis
    $extensoes_disponiveis[] = ".jpeg";
    $extensoes_disponiveis[] = ".jpg";
    $extensoes_disponiveis[] = ".png";
    $extensoes_disponiveis[] = ".gif";
    $extensoes_disponiveis[] = ".bmp";
    // nome imagem
    $nome_imagem = $fotos['tmp_name'];
    $nome_imagem_real = $fotos['name'];
    // dimensoes da imagem
    $image_info = getimagesize($_FILES["foto"]["tmp_name"]);
    $largura_imagem = $image_info[0];
    $altura_imagem = $image_info[1];
    // extencao
    $extensao_imagem = "." . strtolower(pathinfo($nome_imagem_real, PATHINFO_EXTENSION));
    // nome final de imagem
    $nome_imagem_final = md5($nome_imagem_real . $data_atual) . $extensao_imagem;
    $nome_imagem_final_miniatura = md5($nome_imagem_real . $data_atual . $data_atual) . $extensao_imagem;
    // endereco final de imagem
    $endereco_final_salvar_imagem = $pasta_upload . $nome_imagem_final;
    $endereco_final_salvar_imagem_miniatura = $pasta_upload . $nome_imagem_final_miniatura;
    // informa se a extensao de imagem e permitida
    $extensao_permitida = retorne_elemento_array_existe($extensoes_disponiveis, $extensao_imagem);
    // se nome for valido entao faz upload
    if ($nome_imagem != null and $nome_imagem_real != null and $extensao_permitida == true) {
        // upload de imagem normal
        $image = new SimpleImage();
        $image->load($nome_imagem);
        // aplica escala
        if ($largura_imagem > $novo_tamanho_imagem) {
            $image->resizeToWidth($novo_tamanho_imagem);
        }
        // salva a imagem grande
        $image->save($endereco_final_salvar_imagem);
        // upload de miniatura
        if ($upload_miniatura == true) {
            $image = new SimpleImage();
            $image->load($nome_imagem);
            // modo de redimencionar
            if ($largura_imagem > $novo_tamanho_imagem_miniatura) {
                $image->resizeToWidth($novo_tamanho_imagem_miniatura);
            }
            // salva a imagem em miniatura
            $image->save($endereco_final_salvar_imagem_miniatura);
        }
        // array de retorno
        $retorno['normal'] = $host_retorno . $nome_imagem_final;
        $retorno['miniatura'] = $host_retorno . $nome_imagem_final_miniatura;
        $retorno['normal_root'] = $endereco_final_salvar_imagem;
        $retorno['miniatura_root'] = $endereco_final_salvar_imagem_miniatura;
        // retorno
        return $retorno;
    }
}
开发者ID:xcution,项目名称:SitepressCMS,代码行数:60,代码来源:upload_imagem_unica.php

示例5: resizeImagesInFolder

function resizeImagesInFolder($dir, $i)
{
    if (!is_dir('cover/' . $dir)) {
        toFolder('cover/' . $dir);
    }
    $files = scandir($dir);
    foreach ($files as $key => $file) {
        if ($file != '.' && $file != '..') {
            if (!is_dir($dir . '/' . $file)) {
                echo $dir . '/' . $file;
                $image = new SimpleImage();
                $image->load($dir . '/' . $file);
                if ($image->getHeight() < $image->getWidth()) {
                    $image->resizeToWidth(1920);
                } else {
                    $image->resizeToHeight(1920);
                }
                // $new = 'cover/' . $dir . '/'.$image->name;
                if ($i < 10) {
                    $new = 'cover/' . $dir . '/00' . $i . '.' . $image->type;
                } elseif ($i < 100) {
                    $new = 'cover/' . $dir . '/0' . $i . '.' . $image->type;
                } else {
                    $new = 'cover/' . $dir . '/' . $i . '.' . $image->type;
                }
                $image->save($new);
                echo ' ---------> ' . $new . '<br>';
                $i++;
            } else {
                resizeImagesInFolder($dir . '/' . $file, 1);
            }
        }
    }
}
开发者ID:locnd,项目名称:demo,代码行数:34,代码来源:resize.php

示例6: _generateThumbnail

 /**
  * Generates the thumbnail for a given file.
  */
 protected function _generateThumbnail()
 {
     $image = new SimpleImage();
     $image->load($this->source);
     $image->resizeToWidth(Configure::read('Image.width'));
     $image->save($this->thumb_path);
 }
开发者ID:johnulist,项目名称:Markab,代码行数:10,代码来源:thumbnail.php

示例7: processScreenshots

function processScreenshots($gameID)
{
    ## Select all fanart rows for the requested game id
    $ssResult = mysql_query(" SELECT filename FROM banners WHERE keyvalue = {$gameID} AND keytype = 'screenshot' ORDER BY filename ASC ");
    ## Process each fanart row incrementally
    while ($ssRow = mysql_fetch_assoc($ssResult)) {
        ## Construct file names
        $ssOriginal = $ssRow['filename'];
        $ssThumb = "screenshots/thumb" . str_replace("screenshots", "", $ssRow['filename']);
        ## Check to see if the original fanart file actually exists before attempting to process
        if (file_exists("../banners/{$ssOriginal}")) {
            ## Check if thumb already exists
            if (!file_exists("../banners/{$ssThumb}")) {
                ## If thumb is non-existant then create it
                $image = new SimpleImage();
                $image->load("../banners/{$ssOriginal}");
                $image->resizeToWidth(300);
                $image->save("../banners/{$ssThumb}");
                //makeFanartThumb("../banners/$ssOriginal", "../banners/$ssThumb");
            }
            ## Get Fanart Image Dimensions
            list($image_width, $image_height, $image_type, $image_attr) = getimagesize("../banners/{$ssOriginal}");
            $ssWidth = $image_width;
            $ssHeight = $image_height;
            ## Output Fanart XML Branch
            print "<screenshot>\n";
            print "<original width=\"{$ssWidth}\" height=\"{$ssHeight}\">{$ssOriginal}</original>\n";
            print "<thumb>{$ssThumb}</thumb>\n";
            print "</screenshot>\n";
        }
    }
}
开发者ID:dave7y,项目名称:thegamesdb,代码行数:32,代码来源:GetArt.php

示例8: xulyImage

function xulyImage($img, $urlImgTemp, $urlImg, $urlImgThumb, $original = 1)
{
    $file = $urlImgTemp . $img;
    $sizeInfo = getimagesize($file);
    if (is_array($sizeInfo)) {
        include_once 'libraries/SimpleImage.php';
        $image = new SimpleImage();
        $image->load($file);
        $width = $sizeInfo[0];
        $height = $sizeInfo[1];
        if ($width <= IMAGE_THUMB_WIDTH && $height <= IMAGE_THUMB_HEIGHT) {
            copy($file, $urlImgThumb . $img);
        } elseif ($width >= $height) {
            $image->resizeToWidth(IMAGE_THUMB_WIDTH);
            $image->save($urlImgThumb . $img);
        } elseif ($width < $height) {
            $image->resizeToHeight(IMAGE_THUMB_HEIGHT);
            $image->save($urlImgThumb . $img);
        }
        if ($original == 1) {
            $image->load($file);
            if ($width >= $height && $width > IMAGE_MAX_WIDTH) {
                $image->resizeToWidth(IMAGE_MAX_WIDTH);
                $image->save($urlImg . $img);
            } elseif ($width <= $height && $height > IMAGE_MAX_HEIGHT) {
                $image->resizeToHeight(IMAGE_MAX_HEIGHT);
                $image->save($urlImg . $img);
            } else {
                copy($file, $urlImg . $img);
            }
            if (file_exists($file)) {
                unlink($file);
            }
        } else {
            if (copy($file, $urlImg . $img)) {
                if (file_exists($file)) {
                    unlink($file);
                }
            }
        }
        return true;
    } else {
        return false;
    }
}
开发者ID:hieunhan1,项目名称:all-website-v5,代码行数:45,代码来源:controlAjaxAdmin.php

示例9: _write_product_image

 private function _write_product_image($file = '', $prd_id = '')
 {
     $val = rand(999, 99999999);
     $image_name = "PRO" . $val . $prd_id . ".png";
     //$this->upload_image($file, $image_name);
     $this->request->data['Product']['image'] = $image_name;
     $this->request->data['Product']['id'] = $prd_id;
     $this->Product->save($this->request->data, false);
     /* if (!empty($file)) {
            $this->FileWrite->file_write_path = PRODUCT_IMAGE_PATH;
            $this->FileWrite->_write_file($file, $image_name);
        }*/
     include "SimpleImage.php";
     $image = new SimpleImage();
     if (!empty($file)) {
         $image->load($file['tmp_name']);
         $image->save(PRODUCT_IMAGE_PATH . $image_name);
         $image->resizeToWidth(150, 150);
         $image->save(PRODUCT_IMAGE_THUMB_PATH . $image_name);
     }
 }
开发者ID:89itworld,项目名称:pricecomparison,代码行数:21,代码来源:WoolworthsController.php

示例10: get

 public static function get($image_url, $width = NULL)
 {
     $cached_image = '';
     if (!empty($image_url)) {
         // Get file name
         $exploded_image_url = explode("/", $image_url);
         $image_filename = end($exploded_image_url);
         $exploded_image_filename = explode(".", $image_filename);
         $extension = end($exploded_image_filename);
         // Image validation
         if (strtolower($extension) == "gif" || strtolower($extension) == "jpg" || strtolower($extension) == "png") {
             $cached_image = self::$image_path . $image_filename;
             // Check if image exists
             if (file_exists($cached_image)) {
                 return $cached_image;
             } else {
                 // Get remote image
                 $ch = curl_init();
                 curl_setopt($ch, CURLOPT_URL, $image_url);
                 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                 $image_to_fetch = curl_exec($ch);
                 curl_close($ch);
                 // Save image
                 $local_image_file = fopen($cached_image, 'w+');
                 chmod($cached_image, 0755);
                 fwrite($local_image_file, $image_to_fetch);
                 fclose($local_image_file);
                 // Resize image
                 if (!is_null($width)) {
                     $image = new SimpleImage();
                     $image->load($cached_image);
                     $image->resizeToWidth($width);
                     $image->save($cached_image);
                 }
             }
         }
     }
     return $cached_image;
 }
开发者ID:arielcr,项目名称:image-cache,代码行数:39,代码来源:Cache.php

示例11: htmlentities

if (isset($_SERVER['QUERY_STRING'])) {
    $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if (isset($_POST["MM_insert"]) && $_POST["MM_insert"] == "form1") {
    include 'simple_image.php';
    // define constant for upload folder
    define('UPLOAD_DIR', 'C:\\inetpub\\vhosts\\wsso.org\\httpdocs\\staging/extra_images/');
    // replace any spaces in original filename with underscores
    $file = str_replace(' ', '_', $_FILES['image']['name']);
    // create an array of permitted MIME types
    $permitted = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/png');
    $uid = uniqid();
    $file = $uid . "_" . $file;
    $image = new SimpleImage();
    $image->load($_FILES['image']['tmp_name'], UPLOAD_DIR . $file);
    $image->resizeToWidth(338);
    $image->save(UPLOAD_DIR . $file);
    $insertSQL = sprintf("INSERT INTO x_wp_extra_conductor (ex_id, conductor, conductor_image) VALUES (%s, %s, %s)", GetSQLValueString($_POST['ex_id'], "int"), GetSQLValueString($_POST['conductor'], "text"), GetSQLValueString($file, "text"));
    mysql_select_db($database_x_wsso, $x_wsso);
    $Result1 = mysql_query($insertSQL, $x_wsso) or die(mysql_error());
    $insertGoTo = "event_detail.php?post_id=" . $colname_get_extra;
    if (isset($_SERVER['QUERY_STRING'])) {
        $insertGoTo .= strpos($insertGoTo, '?') ? "&" : "?";
        $insertGoTo .= $_SERVER['QUERY_STRING'];
    }
    header(sprintf("Location: %s", $insertGoTo));
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
开发者ID:TheMysticalSock,项目名称:westmichigansymphony,代码行数:31,代码来源:conductor_add.php

示例12: chmod

     if (is_dir($uploaddir)) {
         if (chmod($uploaddir, 0777)) {
             $intBool = chmod($uploaddir, 0777);
             if (!$intBool) {
                 $strErrormessage .= "Please give premission to the upload folder in images folder as 777.<br>";
                 $intError = 0;
             }
         }
     }
     if ($_FILES['img']['error'] == 0) {
         if ($strExtension == "jpg" || $strExtension == "jpeg" || $strExtension == "gif" || $strExtension == "png") {
             if (move_uploaded_file($_FILES['img']['tmp_name'], $uploadfile)) {
                 if ($width > 100) {
                     $image = new SimpleImage();
                     $image->load($uploadfile);
                     $image->resizeToWidth(100);
                     $image->save($uploadfile);
                 }
                 $strfilename = $filename;
             }
         } else {
             $strErrormessage .= "Please upload only gif, jpg or png image.<br>";
             $intError = 0;
         }
     }
 }
 if ($intError) {
     foreach ($_POST as $key => $value) {
         $_POST[$key] = mysql_escape_string(trim($value));
     }
     $sql = "INSERT INTO tblmodule(id,course_id,page_name,mname,by_whom,mdescription,img_path,morder,fname,dtcreated) VALUES('','" . $_POST["course_id"] . "','" . $_POST["page_name"] . "','" . $_POST["mname"] . "','" . $_POST["by_whom"] . "','" . $_POST["mdescription"] . "','" . $strfilename . "','" . $_POST["morder"] . "','" . $_POST["fname"] . "','" . date("Y-m-d H:i:s") . "')";
开发者ID:amoldclarion,项目名称:ICRS,代码行数:31,代码来源:addmodule.php

示例13: uploadImage

function uploadImage($fileID, $directory, $imageWidth = NULL, $imageHeight = NULL, $thumbWidth = NULL, $thumbHeight = NULL)
{
    /*
    echo "imageWidth = |" . $imageWidth . "|<br />";
    echo "imageHeight = |" . $imageHeight . "|<br />";
    echo "thumbWidth = |" . $thumbWidth . "|<br />";
    echo "thumbHeight = |" . $thumbHeight . "|<br />";	
    */
    $FILE = $_FILES[$fileID]['tmp_name'];
    $FILE_NAME = $_FILES[$fileID]['name'];
    $fileName_final = cleanForShortURL($FILE_NAME);
    if ($FILE != NULL) {
        //////////// BIG IMAGE  /////////////////////////////////////////////////////////
        // If big image is required.
        if ($imageWidth != NULL || $imageHeight != NULL) {
            if (is_numeric($imageWidth) || is_numeric($imageHeight)) {
                // resample image
                $image = new SimpleImage();
                $image->load($FILE);
                if (is_numeric($imageWidth) && is_numeric($imageHeight)) {
                    if ($image->getWidth() > $imageWidth || $image->getHeight() > $imageHeight) {
                        if ($image->getWidth() > $imageWidth) {
                            $image->resizeToWidth($imageWidth);
                        }
                        if ($image->getHeight() > $imageHeight) {
                            $image->resizeToHeight($imageHeight);
                        }
                    }
                } else {
                    if (is_numeric($imageWidth) && !is_numeric($imageHeight)) {
                        if ($image->getWidth() > $imageWidth) {
                            $image->resizeToWidth($imageWidth);
                        }
                    } else {
                        if (!is_numeric($imageWidth) && is_numeric($imageHeight)) {
                            if ($image->getHeight() > $imageHeight) {
                                $image->resizeToHeight($imageHeight);
                            }
                        }
                    }
                }
                // if directory doesn't exist, it is created.
                if (!file_exists($directory)) {
                    mkdir($directory, 0777, true);
                }
                // save image into directory.
                $image->save($directory . $fileName_final);
            }
            // close: if(!is_numeric($imageWidth) && !is_numeric($imageHeight))
        } else {
            //Subimos la imagen con sus dimensiones originales (sin resize)
            // if directory doesn't exist, it is created.
            if (!file_exists($directory)) {
                mkdir($directory, 0777, true);
            }
            move_uploaded_file($FILE, $directory . $fileName_final);
            // Moving Uploaded imagen
        }
        //////////// THUMBNAIL  /////////////////////////////////////////////////////////
        // If thumbnail is required.
        if ($thumbWidth != NULL || $thumbHeight != NULL) {
            if (is_numeric($thumbWidth) || is_numeric($thumbHeight)) {
                // resample thumbnail
                $thumb = new SimpleImage();
                $thumb->load($FILE);
                if (is_numeric($thumbWidth) && is_numeric($thumbHeight)) {
                    if ($thumb->getWidth() > $thumbWidth || $thumb->getHeight() > $thumbHeight) {
                        if ($thumb->getWidth() > $thumbWidth) {
                            $thumb->resizeToWidth($thumbWidth);
                        }
                        if ($thumb->getHeight() > $thumbHeight) {
                            $thumb->resizeToHeight($thumbHeight);
                        }
                    }
                } else {
                    if (is_numeric($thumbWidth) && !is_numeric($thumbHeight)) {
                        if ($thumb->getWidth() > $thumbWidth) {
                            $thumb->resizeToWidth($thumbWidth);
                        }
                    } else {
                        if (!is_numeric($thumbWidth) && is_numeric($thumbHeight)) {
                            if ($thumb->getHeight() > $thumbHeight) {
                                $thumb->resizeToHeight($thumbHeight);
                            }
                        }
                    }
                }
                $thumbnailsDirectory = $directory . "thumbs/";
                // if directory doesn't exist, it is created.
                if (!file_exists($thumbnailsDirectory)) {
                    mkdir($thumbnailsDirectory, 0777, true);
                }
                // save thumb into thumbnails directory.
                $thumb->save($thumbnailsDirectory . $fileName_final);
            }
            // close: if(!is_numeric($thumbWidth) && !is_numeric($thumbHeight))
        }
        // close: if($thumbWidth != NULL || $thumbHeight != NULL)
        //////////// THUMBNAIL ENDS HERE /////////////////////////////////////////////////
        // delete temporary uploaded file.
//.........这里部分代码省略.........
开发者ID:designomx,项目名称:eligefacil,代码行数:101,代码来源:uploadFile.php

示例14: intoMedia

 public function intoMedia($endereco_media, $id_estabelecimento_id, $nome_media)
 {
     $vai = new MySQLDB();
     $sql = "SELECT `folder_estabelecimento` FROM `estabelecimento` WHERE `id_estabelecimento`={$id_estabelecimento_id};";
     $result = $vai->ExecuteQuery($sql);
     while ($rows = mysql_fetch_object($result)) {
         $folder = $rows->folder_estabelecimento;
     }
     if ($folder == "") {
         header("Location: vi_estabelecimento.php?vi=nao_folder&ed={$id_estabelecimento_id}");
         exit;
     }
     foreach ($endereco_media['name'] as $key => $ui) {
         $tam_img = getimagesize($endereco_media['tmp_name'][$key]);
         if ($tam_img[0] > 870) {
             include "../../plugins/SimpleImage/SimpleImage.php";
             $image = new SimpleImage();
             $image->load($endereco_media['tmp_name'][$key]);
             $image->resizeToWidth(870);
             $image->save($endereco_media['tmp_name'][$key]);
         }
         if (strpos($endereco_media['type'][$key], "image") === false) {
             $c++;
             $erro .= "{$c} - A foto não &eacute; uma imagem. Arquivo:" . $endereco_media['name'][$key] . "<br />";
         } else {
             $nome_original = $endereco_media['name'][$key];
             list($nome_arquivo, $extensao_arquivo) = explode(".", $nome_original);
             $ds90 = str_replace(" ", "_", $nome_arquivo);
             $numero_reg = rand(1, 999);
             $nome_aleatorio_arquivo = $ds90 . "_foto_" . $numero_reg;
             $logo = "../../../img/bares/" . $folder . "/" . $nome_aleatorio_arquivo . "." . $extensao_arquivo;
             $logo_bd = "bares/" . $folder . "/" . $nome_aleatorio_arquivo . "." . $extensao_arquivo;
             if (!move_uploaded_file($endereco_media['tmp_name'][$key], "./{$logo}")) {
                 $c++;
                 $erro .= "{$c} - Erro no envio da foto.<br />";
             } else {
                 $sql = "INSERT INTO `media` (`nome_media`, `endereco_media`, `id_estabelecimento_id`, `capa`, `visualizar_media`) VALUES ('{$nome_media}', '{$logo_bd}', {$id_estabelecimento_id}, 0, 0);";
                 $vai = new MySQLDB();
                 $vai->ExecuteQuery($sql);
             }
         }
     }
     if ($erro == "") {
         header("Location: vi_estabelecimento.php?vi=foto_upload&ed={$id_estabelecimento_id}");
     } else {
         header("Location: vi_estabelecimento.php?vi=erro_foto_upload&error=" . $erro);
     }
 }
开发者ID:GlauberF,项目名称:Portal-curso-Online,代码行数:48,代码来源:media.class.php

示例15: foreach

 $sub = $_POST['get_sub'];
 foreach ($_FILES['uploadfile']['name'] as $k => $v) {
     $u = new port_menu();
     $u->current_menu($name, 'url', 'id');
     $uploaddir = "../tree/portfolio/img/" . $u->url . "/";
     $uploaddir2 = "tree/portfolio/img/" . $u->url;
     $uploaddir3 = "../tree/portfolio/img/" . $u->url . "/thumb/";
     $apend = date('dHi') . rand(100, 1000);
     $uploadfile = $uploaddir . $apend . basename($_FILES['uploadfile']['name'][$k]);
     $uploadfile2 = $uploaddir3 . $apend . basename($_FILES['uploadfile']['name'][$k]);
     $file = $apend . basename($_FILES['uploadfile']['name'][$k]);
     $u->last_num($u->url, $sub);
     $last_num = $u->number + 1;
     $image = new SimpleImage();
     $image->load($_FILES['uploadfile']['tmp_name'][$k]);
     $image->resizeToWidth(400);
     $image->save($uploadfile2);
     // Копируем файл из каталога для временного хранения файлов:
     if (move_uploaded_file($_FILES['uploadfile']['tmp_name'][$k], $uploadfile)) {
         echo "<h3>Файл успешно загружен на сервер</h3>";
         if (isset($sub) && $sub != '') {
             $sql = "INSERT INTO `portfolio`(`category`, `file_name`, `capture`, `number`, `path`, `sub`) \nVALUES ('" . $u->url . "', '" . $file . "', '" . $text . "', '" . $last_num . "', '" . $uploaddir2 . "', '" . $sub . "')";
         } else {
             $sql = "INSERT INTO `portfolio`(`category`, `file_name`, `capture`, `number`, `path`) \nVALUES ('" . $u->url . "', '" . $file . "', '" . $text . "', '" . $last_num . "', '" . $uploaddir2 . "')";
         }
         if ($mysqli->query($sql) === TRUE) {
             echo "Запись добавлена успешно!";
             //$mysqli->close();
         } else {
             echo "Error: " . $sql . "<br>" . $conn->mysqli_error;
             $_POST['add'] = 0;
开发者ID:serfer89,项目名称:magic,代码行数:31,代码来源:action.php


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