I want to check existence of a folder called $subdomaine
in the directory \cms\sites\
on the keyup.
Here is my script:
<script>
$(document).ready(function(){
$('#subdomain').keyup(subdomain_check);
});
function subdomain_check(){
var subdomain = $('#subdomain').val();
if(subdomain == "" || subdomain.length < 4){
$('#subdomain').css('border', '3px #CCC solid');
$('#tick').hide();
}else{
jQuery.ajax({
type: "POST",
url: "ajax.php",
data: 'subdomain='+ subdomain,
cache: false,
success: function(response){
if(response == 1){
$('#subdomain').css('border', '3px #C33 solid');
$('#tick').hide();
$('#cross').fadeIn();
}else{
$('#subdomain').css('border', '3px #090 solid');
$('#cross').hide();
$('#tick').fadeIn();
}
}
});
}
}
</script>
ajax.php :
<?php
$dirname = $_SESSION["subdomain"];
$filename = DOCUMENT_ROOT."sites/".$dirname;
if (!file_exists($filename)) {
echo "The directory $dirname exists.";
exit;
}
How do I check the existence of the folder at the input ?
Thanks