Login   Register  
PHP Classes
elePHPant
Icontem

File: examples/example1.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of amir hoseinian  >  Image Saver  >  examples/example1.php  >  Download  
File: examples/example1.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Image Saver
Resize an image keeping the size proportions
Author: By
Last change:
Date: 2 years ago
Size: 815 bytes
 

Contents

Class file image Download
<?php 
    
require_once '../ImageSaver.php';
    
define('APPLICATION_PATH'__DIR__);

    
$imageSaver = new ImageSaver();
    
$imageSaver->allowFileTypes = array("jpg","jpeg"); //defining allowed file types

    
if(isset($_FILES['image'])){    
        
$imageSaver->setImage($_FILES['image'])->setName('test')->setPath("\images\\")->resize('auto',300)->save();
    }
?>

<html>
<head>
    <title>image file post example</title>
</head>
<body>
    <form method="post" action="" enctype="multipart/form-data">
        Accepted file types is 
        ( <?php foreach($imageSaver->allowFileTypes as $type) echo $type." ";?>)
        u can add other types in $imageSaver->allowFileTypes property
        <div>
            <lable>image file:<input name="image" type="file"></lable>
        </div>
        <div><input type="submit"></div>
    </form>
    <img src="images/test.jpg" alt="">
</body>
</html>