mkdir() says theres no such directory and fails?

后端 未结 7 2037
逝去的感伤
逝去的感伤 2020-12-16 09:07

Im likely doing something very simply wrong, but when I try to make a directory (using a variable of an insert just performed as the last folder name), I get the error:

7条回答
  •  攒了一身酷
    2020-12-16 09:49

    You shouldn't use is_dir() to check if something exists, you want file_exists() as well. Try:

    if (file_exists("images/listing-images/rent/$insertID") {
        mkdir("images/listing-images/rent/$insertID.");
    }
    

    Have taken the '. out since it looks like a syntax error, but you might have a legitimate reason to keep it in.

    If the mkdir still fails, it could be that images/listing-images/rent doesn't exist, you'll have to create that separately if so.

提交回复
热议问题