PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Estefano Salazar   Resizer   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Como usar la clase
Class: Resizer
Handle and process uploaded images
Author: By
Last change:
Date: 14 years ago
Size: 1,497 bytes
 

Contents

Class file image Download
<!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" xml:lang="en" lang="en">

<head>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
    <meta name="author" content="estefano" />

    <title>Resizer</title>
</head>

<body>

<form action="" method="post" enctype="multipart/form-data">

    <input type="file" name="imagen" id="imagen" /> <br />
    <input type="text" name="width" id="width" value="700" /><br />
    <input type="text" name="height" id="height" value="700" /><br />
    <input type="submit" name="enviar" id="enviar" value="Subir Imagen" />

</form>

<?php

if( $_POST ) {
    if(
$_POST['enviar'] ) {
        if(
$_FILES['imagen']['name'] ) {
            require_once(
"class.resizer.php" );
           
$resizer = new resizer();
           
$n_width = ( $_POST['width'] <= 0 ) ? 700 : $_POST['width'];
           
$n_height = ( $_POST['height'] <= 0 ) ? 700 : $_POST['height'];
            echo
$resizer->resize( $_FILES['imagen']['name'], $_FILES['imagen']['tmp_name'], "archivos/", $n_width, $n_height );
            echo
"<script>window.location=''</script>";
            exit();
        }
    }
}

?>

<h2>Archivos alojados en el servidor</h2>

<ul>
<?php
    $dir
= "archivos/";
   
$fopen = opendir( $dir );
    while(
$archivo = readdir( $fopen ) ) {
        if(
$archivo != "." && $archivo != "..") {
            echo
"<li><a href='$dir$archivo'>$archivo</a></li>";
        }
    }
?>
</ul>

</body>
</html>