0

This is the code I have written to upload the file but the $flag is showing false.

if(isset($_POST['save'])){
    $gallery_title =  mysqli_escape_string($conn,$_POST['gallery_title']);
    if(isset($_FILES['image'])){
        $images = $_FILES['image'];
        $image_name = mysqli_escape_string($conn,md5(time()).$images['name']);
        $image_destination = "../images/gallery/" . $image_name;
        $flag = move_uploaded_file($images['tmp_name'], $image_destination);
        var_dump($flag);
    }
}
Your Common Sense
  • 156,878
  • 40
  • 214
  • 345
  • 1
    Why are you using `mysqli_escape_string`? This is most likely the reason why it doesn't work – Dharman Apr 13 '22 at 12:14
  • You may want to check if there is any file with is_uploaded_file instead of isset. Please check also the absolute path of the destination. Also check your php.ini. open_basedir may prevent you to write to images. – finder2 Apr 13 '22 at 12:24
  • When move_uploaded_file fails, then there is an error. Read the error message. It will explain the problem. – Your Common Sense Apr 13 '22 at 12:53
  • @finder2 there are better ways to fix an error than guesswork – Your Common Sense Apr 13 '22 at 12:55

0 Answers0