<?php
/**
* PhpThumb Library Example File
*
* This file contains example usage for the PHP Thumb Library
*
* PHP Version 5 with GD 2.0+
* PhpThumb : PHP Thumb Library <http://phpthumb.gxdlabs.com>
* Copyright (c) 2009, Ian Selby/Gen X Design
*
* Author(s): Ian Selby <[email protected]>
*
* Licensed under the MIT License
* Redistributions of files must retain the above copyright notice.
*
* @author Ian Selby <[email protected]>
* @copyright Copyright (c) 2009 Gen X Design
* @link http://phpthumb.gxdlabs.com
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
* @version 3.0
* @package PhpThumb
* @subpackage Examples
* @filesource
*/
require_once './phpthumbnailer/ThumbLib.inc.php';
// create variable and store file name
$filename = $_FILES['file_upload']['name'];
// create variable and store temp file name
$tmpname = $_FILES['file_upload']['tmp_name'];
// create variable and store path to save file into server
$storefile = "./upload/".$filename;
// copy file to server
if($_FILES['file_upload']['name']) {
copy($tmpname, $storefile);
unlink ($tmpname);
try {
$thumb = PhpThumbFactory::create("./upload/$filename");
$thumb->adaptiveResize(60, 60);
$thumb->save("./upload/thumb/$filename");
}
catch(Exception $e) { }
}
?>
<!-- Form upload image -->
<form name="upload" id="upload" action="" enctype="multipart/form-data" method="post">
<input type="file" name="file_upload" id="file_upload" />
<input type="submit" name="submit" id="submit" value="submit" />
</form>