PHP Classes

File: upload-02.php

Recommend this page to a friend!
  Classes of Krzysztof Kardasz   Nweb Image   upload-02.php   Download  
File: upload-02.php
Role: Example script
Content type: text/plain
Description: Example
Class: Nweb Image
Perform several image manipulation operations
Author: By
Last change:
Date: 16 years ago
Size: 1,919 bytes
 

Contents

Class file image Download
<?php
/**
 * Nweb Extension Script
 *
 * Example
 *
 * @category Nweb
 * @package Nweb_Scripts
 * @author Krzysztof Kardasz
 * @copyright Copyright (c) euo.pl
 */


   
include 'lib/Image.php';
    include
'lib/ImageException.php';
    include
'lib/ImageUpload.php';
    include
'lib/ImageUploadException.php';

try {

   
$upload = new ImageUpload();

   
//Możemy objąć to w instrukcje if ale nie musimy.
    //Żadna akcja się nie wykona jeśli nie wyślemy formularza.
   
$upload->upload(array('obraz','obraz2','obraz3'));

   
// Na uploadowanych plikach możemy wykonywać różne operacje
    // Oprócz metody: save, compose i display
    // W metodzie Text argument Image automatycznie przyjmuje wartość null,
    // bezwzględu na to jaką mu podamy.
   
$upload->ResizeToWidthHeight(300, 200)->GrayScale();

   
#uploadSave ([string katalog docelowy,] [string nazwa pliku,] [boolean automatyczna zmiana nazw,] [int start numerowania])
   
$upload->uploadSave ('uploads/','zdjecie',true);

   
$Messages = implode('<br />', $upload->GetMessages ());
}

catch (
ImageUploadException $e)
{
    die(
$e->Message());
}

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>ImageUpload - 02</title>
</head>
<body>
<h3><?php echo (!empty($Messages)) ? $Messages : 'Upload zdjęć'; ?></h3>
<form enctype="multipart/form-data" action="" method="post">
<fieldset>
    <legend>Zdjęcia:</legend>
    <label>Obraz</label> <input name="obraz" type="file" /> <br />
    <label>Obraz2</label> <input name="obraz2" type="file" /> <br />
    <label>Obraz3</label> <input name="obraz3" type="file" /> <br />
</fieldset>
 <input type="submit" name="submit" value="Upload" />
</form>

</body>
</html>