Login   Register  
PHP Classes

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Piotr  >  Easy Upload Class  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example of use
Class: Easy Upload Class
Validate and process files uploaded via forms
Author: By
Last change:
Date: 3 years ago
Size: 1,268 bytes


Class file image Download
if($_FILES['server_banner']['error'] != 4) {


            - variable name (<input type="file" name="THIS VALUE" />
            - upload target
            - image dimensions (optional)
            - IMAGE_EQUAL, IMAGE_MAX (optional)
                - image must have defined dimensions
                - you defines max acceptable image dimensions


    $banner = new Upload('server_banner', ROOT.'Upload/banners/', array('468', '60'), IMAGE_EQUAL);


    $banner->MaxSize(204800); // 200 kb

    // If you'll not trigger this method, upload'll accept files of any types

    $banner->AllowFormat('image/jpeg', 'image/gif', 'image/png');
    if(!$banner->Upload()) {
        switch($banner->GetError()) {
            case ERROR_BAD_DIMENSIONS:
                echo 'Bad image dimensions. Acceptable: 468x60px';
            case ERROR_FILE_TOO_BIG:
                echo 'File size exceeds 200kb. Size of an uploaded file is: '.$banner->GetFileSize();
            case ERROR_BAD_FORMAT:
                echo 'Bad file format. Acceptable: jpg, gif, png';

    else echo 'File has been uploaded to '.$banner->GetUploadedName();