Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2014
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. <?php
  2. // checks if the form has been submit
  3. if ( isset($_POST['submit']) ) {
  4. // if errors, display this
  5. if ($_FILES['file']['error'] > 0) {
  6. echo 'Error: ' . $_FILES['file']['error'] . '<br />';
  7. // else if successful...
  8. } else {
  9. // put the file contents into an array
  10. $file_contents_array = array_map('rtrim', file($_FILES['file']['tmp_name']));
  11.  
  12. // this variable contains the file contents as a whole (by merging the array above with implode()
  13. $file_contents_imploded = implode($file_contents_array);
  14.  
  15. echo $file_contents_imploded; // displays the file contents
  16. }
  17. }
  18. ?>
  19. <html>
  20. <body>
  21.  
  22. <form action="?" method="post" enctype="multipart/form-data">
  23. <label for="file">Filename:</label>
  24. <input type="file" name="file" id="file"><br>
  25. <input type="submit" name="submit" value="Submit">
  26. </form>
  27.  
  28. </body>
  29. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement