PHP Classes

File: test/upload.php

Recommend this page to a friend!
  Classes of Ujah Chigozie peter  >  Nano PHP Image Resize  >  test/upload.php  >  Download  
File: test/upload.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Nano PHP Image Resize
Resize local or remote images
Author: By
Last change:
Date: 8 months ago
Size: 875 bytes
 

Contents

Class file image Download
<?php
 
require_once __DIR__ "/autoload.php";

  if(isset(
$_FILES['image'])){
   
$ImageTemp = $_FILES['image']['tmp_name'];
   
$fileName = 'old-image.jpg';
   
$filePathAsset = __DIR__ . '/assets/img/nano/';
   
    if(!
is_dir($filePathAsset)){
      @
mkdir($urlPathAsset, 0777, true);
      @
chmod($urlPathAsset, 0755);
    }

    if(
file_exists($filePathAsset . $fileName)){
      @
unlink($filePathAsset . $fileName);
    }

    if (@
move_uploaded_file($ImageTemp, $filePathAsset . $fileName)) {
     
$imagine = new Peterujah\NanoBlock\NanoImage();
     
$image = $imagine->open($logoPath . $fileName);

     
$image->resize(360, 200, false);
     
$image->save($filePathAsset . $imageName, false, 80, $imagine::JPEG);

     
$image->resize(116, 80, false);
     
$image->save($filePathAsset . $imageName, true, 100, $imagine::JPEG);

     
$image->free();
    }
  }