Guest User

Untitled

a guest
Jan 16th, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. <?php
  2. $servername = "localhost";
  3. $username = "";
  4. $password = "";
  5. $database = "";
  6.  
  7. $file_get = $_FILES['foto']['name'];
  8. $temp = $_FILES['foto']['tmp_name'];
  9. $conn = mysqli_connect($servername, $username, $password, $database);
  10.  
  11. $file_to_saved = "uploads".$file_get;
  12. move_uploaded_file($temp, $file_to_saved);
  13.  
  14. echo $file_to_saved;
  15.  
  16. $insert_img = mysqli_query($conn,"INSERT INTO members (avatar) VALUES ('".$file_to_saved."')");
  17. if ($insert_img) {
  18. # code...
  19. echo "Img inserted successfully";
  20. }
  21. else{
  22. echo "There is something wrong with this code.";
  23. }
  24.  
  25. ?>
  26.  
  27. <form name="imgupl" action="" method="POST" enctype="multipart/form-data">
  28. <input type="file" name="foto">
  29. <p>
  30. <button>Submit Image</button>
  31. </form>
Add Comment
Please, Sign In to add comment