Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype>
- <html>
- <head>
- <title>Upload</title>
- </head>
- <body>
- <?php
- if(!empty($_FILES)){
- extract($_FILES['myfile']);
- $filename = realpath("./") . "/uploads/" . $name;
- move_uploaded_file($tmp_name, $filename);
- $file = base64_encode(fread(fopen($filename, "r"), filesize($filename)));
- $something_that_could_be_stored_and_retrived_in_the_database = "data:" . $type . ";base64,". $file;
- echo "<image src=\"" . $something_that_could_be_stored_and_retrived_in_the_database . "\">";
- } else { ?>
- <fieldset>
- <legend>My upload form</legend>
- <form method="POST" action="./index.php" enctype="multipart/form-data">
- <input type="file" name="myfile">
- <input type="submit" value="Let's get this upload started!">
- </form>
- </fieldset>
- <?php } ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement