Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Upload an image</title>
- </head>
- </body>
- <form action="test.php" method="POST" enctype="multipart/form-data">
- <p>Ladda upp bild.</p>
- <input type="file" name="image">
- <input type="submit" value="Upload">
- </form>
- </body>
- </html>
- <?php
- //anslut
- require "anslut.php";
- //file properties
- $file = $_FILES['image'] ['tmp_name'];
- if(!isset($file)) {
- echo "Please selecet an image.";
- } else {
- $image = file_get_contents($_FILES['image'] ['tmp_name']);
- $image_name = $_FILES['image'] ['name'];
- $image_size = getimagesize($_FILES['image'] ['tmp_name']);
- if ($image_size==FALSE){
- echo "Thatś not an image.";
- } else {
- if (!$insert = mysql_query("INSERT INTO images VALUES ('', '$image_name', '$image')")) {
- echo "Problem uploading image";
- } else {
- $lastid = mysql_insert_id();
- echo "image uploaded.<p />Your image:<p /><img src=get.php?id=$lastid>";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement