Jump to content
xisto Community
mahirharoon

File Checker-how To Check File Whith Html Through Html?

Recommended Posts

edit:sorry for the mistake it is php not html
and its with not whith
my code checking script=

<?php$file = '$CHECK';if (file_exists($file)) {	echo "The file $filename exists";} else {	echo "The file $filename does not exist";}?>
my question is how to check the file whith html
example:on a page a text box is provided and a button
the user writes a file name (or website)
the user clicks on the submit button
then it checks and show it (with the code above)

i got the code
<?php$filename=$_POST['check'];if (file_exists($filename)) {	echo "The file $filename exists";} else {	echo "The file $filename does not exist";}?> <form method="post"><input name="check"><input type="submit" /></form>

but......
the problem is , it will first show
$_POST['check']
or
Notice: Undefined index: check in path\to\filecheck.php on line 2
The file does not exist
Edited by mahirharoon (see edit history)

Share this post


Link to post
Share on other sites

thanks alex the programmer
i used it for my project

<?php$filename=$_POST['check'];if (@file_exists($filename)) {	echo "The file $filename exists";} else {	echo "The file $filename does not exist , and the non existing file is created";		  fopen("$filename", "a+");}?> <form method="post"><input name="check"><input type="submit" /></form>
now it checks whether it i there and makes one if not existing
Edited by mahirharoon (see edit history)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.