Login   Register  
PHP Classes
elePHPant
Icontem

File: sample.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Jonathan Alexey  >  UploadFile  >  sample.php  >  Download  
File: sample.php
Role: Example script
Content type: text/plain
Description: sample to use
Class: UploadFile
Process uploaded image files
Author: By
Last change: Change samples..
Date: 2010-01-22 02:20
Size: 1,301 bytes
 

Contents

Class file image Download
<?php
/* to use this class you 
most specify the folder, img/tmp/ and img/upload/
*/
include("uploadImage.Class.php");
if(isset(
$_POST['btn1']) and $_POST['btn1']=="Send1") {
    
// Sample to use -- Upload only a image type
    
$nome=$_FILES['file']['name'];
    
$tmp_nome=$_FILES['file']['tmp_name'];
    
$tamanho=$_FILES['file']['size'];
    
$tipo=$_FILES['file']['type'];
    
$erro=isset($_FILES['file']['erro']);
    
$file=new uploadImage($nome,$tmp_nome,$tamanho,$tipo,$erro);
    
$file->setExtension("jpeg");
    
$file->setExtension("gif");
    
$file->setExtension("png");
    
$file->setExtension("jpg");
    
$file->setDestinationImage("img/tmp/","img/upload/");
    
$file->setMaxHeight(801);
    
$file->setMaxWidth(601);
    
$file->setMaxSize(200);
    
$file->newNameFile();
    if(
$file->moveImage()){
        echo 
"Upload ok: <a href='img/upload/".$file->getName()."'>".$file->getName()."</a> <br>";
        echo 
"<input type='image' name='image' id='image' src=img/upload/".$file->getName().">";
    }else{
        echo 
" --- errro ---- ";    
    }
}
?>
<html>
<head>
</head>
<body>
<form action="" method="post" enctype="multipart/form-data" name="form1">
  Upload image file only:
  <input type="file" name="file" id="file">
  <input type="submit" name="btn1" id="btn1" value="Send1">
</form>
<p>

  </p>
</body>
</html>