Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // checks if the form has been submit
- if ( isset($_POST['submit']) ) {
- // if errors, display this
- if ($_FILES['file']['error'] > 0) {
- echo 'Error: ' . $_FILES['file']['error'] . '<br />';
- // else if successful...
- } else {
- // put the file contents into an array
- $file_contents_array = array_map('rtrim', file($_FILES['file']['tmp_name']));
- // this variable contains the file contents as a whole (by merging the array above with implode()
- $file_contents_imploded = implode($file_contents_array);
- echo $file_contents_imploded; // displays the file contents
- }
- }
- ?>
- <html>
- <body>
- <form action="?" method="post" enctype="multipart/form-data">
- <label for="file">Filename:</label>
- <input type="file" name="file" id="file"><br>
- <input type="submit" name="submit" value="Submit">
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement