Advertisement
Guest User

Untitled

a guest
Dec 4th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. <?php
  2. $servername ="localhost";
  3. $user ="root";
  4. $pass= "";
  5. $db ="img_upload";
  6.  
  7. $conn = new mysqli($servername,$user,$pass,$db);
  8.  
  9. if(isset($_POST['upload'])){
  10.  
  11. $description= $_POST["description"];
  12. $file_tmp = $_FILES["img_file"]["tmp_name"];
  13. $file_name = $_FILES["img_file"]["name"];
  14. $file_type = $_FILES["img_file"]["type"];
  15. $file_path = "images/".$file_name;
  16.  
  17. move_uploaded_file($file_tmp, $file_path);
  18.  
  19. $sql = "INSERT INTO img_list(img_tmp,img_name,img_type,description) VALUES ('$file_tmp','$file_name','$file_type','$description')";
  20. $result = $conn->query($sql);
  21. if ($result) {
  22. echo "<script>";
  23. echo "alert('Image successfully uploaded');";
  24. echo "</script>";
  25.  
  26. }
  27. else{
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement