Advertisement
Guest User

Untitled

a guest
Dec 9th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. if(isset($_POST['upload']))
  2. {
  3. $target = $_FILES['image']['name'];
  4. $target_dir = "image/";
  5. $target = $target_dir.basename($_FILES['image']['name']);
  6. $sql = "INSERT INTO uploadimage (image) VALUE ('$target')";
  7.  
  8.  
  9.  
  10. // This is an if statement to say if the target directory exists then set permissions.
  11. if (!file_exists($target_dir) )
  12. {
  13. mkdir ($target_dir, 0744);
  14.  
  15. }
  16.  
  17.  
  18.  
  19. // This part of the code is to say if the image is uploaded correctly or not and show an error message.
  20. if(move_uploaded_file($_FILES['image']['tmp_name'], $target))
  21. {
  22. echo " Image has been uploaded ";
  23.  
  24. }
  25. else
  26. {
  27. echo "Error while uploading";
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement