PHP Classes

File: test.php

Recommend this page to a friend!
  Classes of Taiwo Peace   Secure Upload   test.php   Download  
File: test.php
Role: Example script
Content type: text/plain
Description: Example Usage
Class: Secure Upload
Process uploaded files of multiple types
Author: By
Last change: nothing much
Date: 9 years ago
Size: 1,394 bytes
 

Contents

Class file image Download



<?php
//please do not forget to rate this class if it is usefull, and if you have any complaint or recommendation , please leave a comment at the forum session

require_once 'upload.php'; ?>
<!--make sure the enctype="multipart/form-data" is used in the form attributes -->
<form method="POST" action="<? echo $_SERVER['PHP_SELF'] ; ?>" enctype="multipart/form-data">
<input type="file" name="pic" />
<input type="submit" value="upload" />
</form>
<?php

$upload
=new upload();

//set the file type here ... available options $upload->filetype='image' or 'audio' or 'document' or 'any'
$upload->filetype='image';

// specify the input name here
$upload->inputname='pic';

//specify the upload path
$upload->uploadpath='upload/';
//set allowed size in kilobyte , 1024kb make 1megabyte
$upload->allowedsize=100000;

//if there is no restriction in the dimension of image or if document type is not image , there is no need to including $upload->height=120; and $upload->width=120; in your code
//set image height in pixel ,
$upload->height=120;
//set image width in pixel ,
$upload->width=120;

//check if upload is successfull
if($upload->upload()==false){
//eco the reasin for the error
echo $upload->error;
}

else{

//echo the imagename, this name can be inserted into a database for referencing
echo $imgname=$upload->imgname;
}
?>