Monday, 18 August 2014

File Uploading Using PHP

Posted by D. arunkumar  |  No comments

                             In This Tutorial We Will See how to upload a file


HTML FORM:
   
        
 <html>  
 <h1 align="center">SAMPLE FORM</h1>    
 <br><br>  
 <form action="UploadTest.php" method="post" enctype="multipart/form-data">  
 <table style="font-family:verdana;font-size:17px" width="50%">  
 <tr height="50">  
 <td>NAME</td>    
 <td><input type="text" name="t1" size="30"></td>  
 </tr>  
 <tr height="50">  
 <td>AGE</td>    
 <td><input type="text" name="t2" size="30"></td>  
 </tr>  
 <tr height="50">  
 <td>PROFILE</td>    
 <td><input type="file" name="t3" size="30"></td>  
 </tr>  
 <tr height="50">  
 <td colspan="2" align="center">  
 <input type="submit" value="REGISTER">    
 </td>    
 </tr>  
 </table>  
 </form>  
 </body>  
 </html>  
Uploadtest.php
   
       
 <?php  
 echo "<h1>";  
 //if($_FILES['t3']['error']==0)  
 if($_FILES['t3']['error']==0 && $_FILES['t3']['type']=="text/plain" && $_FILES['t3']['size']==25)  
 {  
 $res=move_uploaded_file($_FILES['t3']['tmp_name'], "Upload/".$_FILES['t3']['name']);  
 if($res)  
  echo "File Uploaded!!!";    
 else  
  echo "File could not be uploaded!!".$_FILES['t3']['error'];   
 }  
 else  
   echo "Pl upload only text files !!! <br> U have uploaded ".$_FILES['t3']['type']." file";  
 ?>  

11:32 Share:

0 comments:

Get updates in your email box
Complete the form below, and we'll send you the best coupons.

Deliver via FeedBurner
Proudly Powered by Blogger.
back to top