Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. <form action="upload.php" method="POST">
  2. <input type="file" name="image">
  3. <input type="submit" name="submit" value="upload">
  4. </form>
  5. <?php
  6. if(isset($_POST['submit']))
  7. {
  8. $conn= mysqli_connect("localhost","root","");
  9. mysqli_select_db($conn, "namastedb");
  10.  
  11. $imageName = mysqli_real_escape_string($conn, $_FILES["image"] ["name"]);
  12. $imageData = mysqli_real_escape_string($conn, file_get_contents($_FILES["image"] ["tmp_name"]));
  13. $imageType = mysqli_real_escape_string($conn, $_FILES["image"]["type"]);
  14.  
  15. if(substr($imageType, 0, 5) == "image")
  16. {
  17. mysql_query("insert into 'product_details' values('','1','$imageName','$imageData') ");
  18. echo "Image Uploaded.";
  19. }
  20. else
  21. echo "Only images are allowed!";
  22.  
  23. }
  24.  
  25.  
  26. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement