Reading a file in PHP

File Handling in PHP

PHP has many built-in (ready made) functions for handling files.
we can open files from URL (Web) also.

Q1)Accept a file name from user and display the content.

if (isset($_POST['f1']))

   if ( ! (file_exists( $file ) ) ) 
             echo "$file does not exist<br/>";

   $data = file_get_contents( $file);
   echo $data;

 <body><form method=post>
 <input type=file name="f1"><input type=submit value=read>

No comments:

Post a Comment

Thanks for visiting my Blog!

Have a Question ? Need Help in College Assignments, Need Code that is not available here? Just leave a comment & get your code instantly.

Tips to Enhance Your Blog