Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if($_SERVER["REQUEST_METHOD"] == "POST")
- {
- $pmdontshowfinish=0;
- function handleupload()
- {
- include_once('../admin/inc/easyphpthumbnail.class.php');
- include_once('../admin/inc/watermark.php');
- $thumb = new easyphpthumbnail;
- // Set thumbsize - automatic resize for landscape or portrait
- $thumb -> Thumbheight = 135;
- // Set thumbsize to 200px width
- $thumb -> Thumbwidth = 135;
- $replace_values = array(" ", "'", "\"", "\\", "/", "?", "|", "@", "#", "~", "!", "£", "$", "%", "^", "&", "*", "(", ")", "[", "]", "{", "}", "+", "=", "-", ":", ";", ",");
- global $pmdontshowfinish;
- if (is_uploaded_file($_FILES['userfile']['tmp_name']))
- {
- $realname = $_FILES['userfile']['name'];
- //--chking extension
- if(!preg_match("/(\.jpg|\.png|\.gif|\.bmp|\.jpeg)$/i",$realname))
- die();
- //--end chking extension
- if ($_FILES['userfile']['size']>100)
- {
- $empty=""; //delibrately made empty
- echo "<script language=\"JavaScript\">";
- echo "fname = '" . $empty . "'";
- echo "</script>";
- echo "Uploaded files must be less than 1000k. Please close this window and try again";
- }
- else
- {
- switch($_FILES['userfile']['error'])
- { case 0: $mess = "<br /> ";
- break;
- case 1:
- case 2: $mess = "Error : File size more than 512000 bytes";
- break;
- case 3: $mess = "Error : File partially uploaded";
- break;
- case 4: $mess = "Error : No File Uploaded";
- break;
- }
- echo $mess . " ";
- mt_srand( (double)microtime() * 100);
- $randvar = mt_rand(1,100);
- settype($randvar,"string");
- $newfilename = "./images/" . $randvar. str_replace($replace_values, "_",$realname);
- //echo $newfilename;
- $shortfname = $randvar. str_replace($replace_values, "_",$realname);
- while ( file_exists($newfilename) != FALSE )
- {
- $randvar = mt_rand(1,100);
- settype($randvar,"string");
- $newfilename = "./images/" . $randvar. str_replace($replace_values, "_",$realname);
- $shortfname = $randvar. str_replace($replace_values, "_",$realname);
- }
- copy($_FILES['userfile']['tmp_name'], $newfilename);
- $source= $newfilename;
- $watermarked_destination = $newfilename;
- $watermark_options = array(
- 'watermark' => "../admin/images/watermark.png",
- 'halign' => Watermark::ALIGN_RIGHT,
- 'valign' => Watermark::ALIGN_BOTTOM,
- 'hshift' => -10,
- 'vshift' => -10,
- 'type' => IMAGETYPE_JPEG, // Save result in JPEG to minimize file size
- 'jpeg-quality' => 90,
- );
- Watermark::output($source, $watermarked_destination, $watermark_options);
- $thumb -> Thumblocation = './images/';
- $thumb -> Thumbprefix = 'thumb_';
- $thumb -> Thumbsaveas = 'jpg';
- $thumb -> Thumbfilename = './images/'.$newfilename;
- $thumb -> Createthumb($newfilename,'file');
- echo "<img src='".$newfilename."'>";
- }// Else fr more than 60k
- } //end if second top most i.e. size <
- else
- {
- echo "<div align=center>Error : File Not Uploaded. Check Size & Try Again.<br><a href=\" javascript: onclick=history.go(-1);\">Go Back</a></div>";
- $pmdontshowfinish = 1;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement