NEP -PHP PROGRAMMING

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6 PROGRAM 7 PROGRAM 8 PROGRAM 9 PROGRAM 10 PROGRAM 11 PROGRAM 12 PROGRAM 13 PROGRAM 14

PART B

. . .

 
   
  
 12.Write a PHP program to upload a file.
  
 Note : create folder 'Data' in same place
 
---------Page.1: program12.php-------------------------
<html>
<body>

<form action="program12S.php" method="post" 
enctype="multipart/form-data">
    Select image to upload:
    <input type="file" name="file" id="file"/>
    <input type="submit" value="Upload Image" name="submit"/
>
</form>


------Page.2=program12S.php----------------------------

< ?php

 $UPLOADPATH="data/";
 
		
 try{
		 	 
		if ( 0 < $_FILES['file']['error'] ) 
			{
			        echo 'Error: ' . $_FILES['file']['error'] . '<br>';
			 }
		 else 
		 {
                    move_uploaded_file($_FILES['file']['tmp_name'], $UPLOADPATH .$_FILES['file']['name']);
			}
			$filename=$_FILES['file']['name'];
			$dis=$UPLOADPATH.$filename;
					
					   
			 if($dis=="")
				 echo "file does not exist";
			 else {
					
			      	echo "file uploaded";  
			       echo '<img  src="'.$dis.'" width=400 height=400  />';
 					  }
 					  
		  	 }catch(exception $e){
					 	 	   
			 		echo "false";
   }

?>

</body>
</html>

</body>
</html>