Php Check If Folder Exists

[Solved] Php Check If Folder Exists | Php - Code Explorer | yomemimo.com
Question : php file exist

Answered by : stefan-jilderda

<?php
$filename = '/path/to/foo.txt';
if (file_exists($filename)) {
    echo "The file $filename exists";
} else {
    echo "The file $filename does not exist";
}
?>

Source : https://www.php.net/manual/en/function.file-exists.php | Last Update : Tue, 21 Apr 20

Question : check directory exists in php

Answered by : glorious-gaur-5fxv7g0064cd

<?php
$directory = "./videos/category/";
if (!file_exists($directory)) { mkdir($directory, 0777, true);
}
?>

Source : | Last Update : Tue, 26 Jan 21

Question : php directory exists

Answered by : tiago-frana

$directory = "/var/www/videos/";
if (file_exists($directory) && is_dir($directory))
{ echo "Sure, exists and is dir";
}else{ echo "Not exists. Creating..."; mkdir($directory, 0777, true);
}

Source : | Last Update : Mon, 31 Jan 22

Question : php check if folder exists

Answered by : encouraging-eagle-257ub9oodfwl

<?php
$filename = '/path/to/foo.txt';
if (file_exists($filename)) {
    echo "The file $filename exists";
} else {
    echo "The file $filename does not exist";
}
?>

Source : https://www.php.net/manual/en/function.file-exists.php | Last Update : Tue, 08 Dec 20

Answers related to php check if folder exists

Code Explorer Popular Question For Php