Login   Register  
PHP Classes
elePHPant
Icontem

File: upload.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of nanou morgan  >  noticeboard  >  upload.php  >  Download  
File: upload.php
Role: ???
Content type: text/plain
Description: check picture then upload
Class: noticeboard
Author: By
Last change:
Date: 2001-02-12 16:57
Size: 3,754 bytes
 

Contents

Class file image Download
<?

include  ('template.inc');

include  ('variable.inc');


$dir = $path_pix;  // Base directory

 
 if (is_uploaded_file($userfile)) {
 
  $handle=opendir($dir);
    
    while ($file = readdir($handle)) {
        
       
         if ($file == $userfile_name){
         
$NN = time();
$NewExt1 = $NN.'.gif';
$NewExt2 = $NN.'.jpg';
         
         $userfile_name= ereg_replace("\.gif", "$NewExt1", $userfile_name);
         $userfile_name= ereg_replace("\.jpg", "$NewExt2", $userfile_name);
         
         }
        
    }
    closedir($handle); 
    
     //$userfile_name= ereg_replace('.gif', 'X.gif', $userfile_name);
 
 $SAVE_FILE = $path_pix."$userfile_name";
 


copy($userfile, "$SAVE_FILE");
$image_file ="$SAVE_FILE";
$image_size = getimagesize($image_file);
unlink ($SAVE_FILE);

if (($image_size[0] >$pix_wide)||($image_size[1] >$pix_high)){
 $title="Error -  Your file has not been uploaded";
  $content .= "<font face=\"Helvetica,Arial,Geneva\"><font size=\"2\"><b>$title</b></font><br>
  <blockquote><font face=\"Helvetica,Arial,Geneva\"><font size=\"2\">Your File is too wide, it needs to be less than $pix_wide pixels wide or less than $pix_high pixels high.
  </font><FORM><INPUT TYPE=\"button\"  VALUE=\"Back 1 step\" onClick=\"history.go(-1)\"></font> </center></p>
</FORM>
</blockquote>
  ";

}
	else{
	
	  

     copy($userfile, "$SAVE_FILE");
     $image_file ="$SAVE_FILE";
	$image_size = getimagesize($image_file);
	
     $title="Success -  Your file has been uploaded";
	$content .= "<font face=\"Helvetica,Arial,Geneva\"><font size=\"2\"><b>$title</b></font><br>
	<blockquote>
 	Name : $userfile_name  <br> \n
	Size : $userfile_size <br> \n
	Type : $userfile_type <br> \n
	View it : <a href=\"$view_pix/$userfile_name\">$userfile_name</a> <br> \n

	<br><img src=\"/noticeboard2/pix/$userfile_name\" $image_size[3]><br>\n
	Image width = <font color=\"red\">$image_size[0]</font><br>\n
	Image height = <font color=\"red\">$image_size[1]</font><br>\n
	Image type = <font color=\"red\">$image_size[2]</font><br>\n
	Image html string = <font color=\"red\">$image_size[3]</font><br>\n
	<FORM ACTION=\"post.html\" METHOD=POST>
	<input type=\"hidden\" name=\"width\" value=\"$image_size[0]\">
	<input type=\"hidden\" name=\"height\" value=\"$image_size[1]\">
	<input type=\"hidden\" name=\"Pix\" value=\"$userfile_name\">
	
	<INPUT TYPE=\"submit\"  VALUE=\"Go and enter Details\"></font> </center></p>
	</FORM></blockquote>

	";
	}

 } else {
 $title="Error -  Your file has not been uploaded";
     $content .= "<font face=\"Helvetica,Arial,Geneva\"><font size=\"2\"><b>$title</b></font><br>
     <blockquote><font face=\"Helvetica,Arial,Geneva\"><font size=\"2\">Your file is too big, you will have to reduce its size to be no more than 24K
     </font><FORM><INPUT TYPE=\"button\"  VALUE=\"Back 1 step\" onClick=\"history.go(-1)\"></font> </center></p>
</FORM>
</blockquote>";
 }

 







/*  parse to template */ 


$t = new Template( $path);
                                  // create a template object named $t 


$t->set_file( "MyFileHandle", "$template");
                                  // set MyFileHandle = our template file 
                                                                    
$t->set_var(array( "TITLE" => $title,
					"FOOTER" => $bot,
				   "CONTENT" =>  $content));
                                  

                                  // set template variable 
$t->parse( "MyOutput", "MyFileHandle"); 
                                  // set template variable MyOutput = parsed file 
$t->p( "MyOutput");  // output the value of MyOutput (our parsed data) 


?>