View Single Post
08-08-2006, 10:54 AM
#8
Nightscream is offline Nightscream
Status: Junior Member
Join date: Aug 2006
Location:
Expertise:
Software:
 
Posts: 58
iTrader: 0 / 0%
 

Nightscream is on a distinguished road

  Old

this is my full code
PHP Code:
<?php
define 
('THUMBWIDTH'100);
define ('THUMBHEIGHT'100);
function 
CreateThumb($src) {
    
copy$filetmpname"$upload_dir'.thumb.'$new_filename);
    list(
$width$height$type$attr) = getimagesize($src);
    
$img imagecreatefromstring(file_get_contents($src));
    
$lowest min(THUMBWIDTH $widthTHUMBHEIGHT $height);
    if(
$lowest 1) {
        
$smallwidth floor($lowest*$width);
        
$smallheight floor($lowest*$height);
        
$tmp imagecreatetruecolor($smallwidth$smallheight);
        
imagecopyresized($tmp$img0000$smallwidth$smallheight$width$height);
        
imagedestroy($img);
        
$img $tmp;
    }
}
function 
CreateWatermark($src) {
    
$img imagecreatefromstring(file_get_contents($src));
    
$red imagecolorallocate($img0xFF0x000x00);
    
imagestring($img533WATERMARK$red);
}
if( isset( 
$_POST['Upload'] )) {
    
$upload_dir $_SERVER['DOCUMENT_ROOT'] . "images/";
    
$MaxFileSize 800000000;
    
$filename $_FILES['file']['name'];
    
$filesize $_FILES['file']['size'];
    
$filetmpname $_FILES['file']['tmp_name'];
    
$allowed_types = array( "jpg""gif""png" );
    
$filetype substr($filename, -33);
    
//$Thumb = $_POST['Thumbnail'];
    //$Water = $_POST['Watermarking'];
    
    
if($filename) {
    echo 
'test';
    
$error 0;
        if((
$filesize $MaxFileSize) | $filesize ) {
            
$error 1;
            
$errmsg .= "Your File is to large, (Max File size: 8MB)";
        }
        if( !
in_array$filetype$allowed_types )) {
            
$error 1;
            
$errmsg .= "Your File is the wrong type, (Allowed Types: Gif, Jpg, Png)//change to the allowed types";
        }else  {
            
$error 0;
        }
        if( 
$error ) {
            die( 
"$errmsg);
        }else{                
            
$num rand19999 );
            
$new_filename $num.$filename;
            
$upload move_uploaded_file($filetmpname"$upload_dir.$new_filename");
            if(
$Thumb ) {
                
CreateThumb($filetmpname);
            }
            if(
$Water ) {
                
CreateWatermark($filetmpname);
            }
            if( 
$upload ) {
                echo 
'Upload Succesfull';
                
//echo "<meta http-equiv='refresh' content='0'; URL='?image=$upload_dir.$new_filename'>";
            
}else {
                die( 
"Cound not upload the file, please try again" );
            }
        }
    }else{
        echo 
"File '$filename' not uploaded";
    }
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
<center>
<script language='JavaScript' type='text/javascript'>
<!--
   if (!document.phpAds_used) document.phpAds_used = ',';
   phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11);

   document.write ("<" + "script language='JavaScript' type='text/javascript' src='");
   document.write ("http://x10hosting.com/advert/adjs.php?n=" + phpAds_random);
   document.write ("&what=zone:1&target=_blank");
   document.write ("&exclude=" + document.phpAds_used);
   if (document.referrer)
      document.write ("&referer=" + escape(document.referrer));
   document.write ("'><" + "/script>");
//-->

</script><noscript><a href='http://x10hosting.com/advert/adclick.php?n=a7fb3e9d' target='_blank'><img src='http://x10hosting.com/advert/adview.php?what=zone:1&n=a7fb3e9d' border='0' alt=''></a></noscript>
<br />
<form action="uploadform.php" method="post">
<input type="file" name="file"><br />
JPG, GIF, PNG uploadable files.<br />
<input type="checkbox" name="Thumbnail"> Thumbnails option<br />
<input type="checkbox" name="Watermarking"> Watermarking option<br />
<input type="submit" name="Upload" value="Upload File">
</form></center>
</body>
</html>