• $file = “/home/mywebsite/public_html/wp/wp-content/uploads/2021/10/somefile.txt”;

    if (file_exists($file)) {
    $hFl = fopen($file,”a”);
    } else {
    $hFl = fopen($file,”c”);
    }

    today I found a situation where folder 10 wasn’t created and so this logic fails to create somefile.txt

    is there a switch to cause the folder to be generated at the same time as the file?

  • The topic ‘fopen fails when folder is missing’ is closed to new replies.