Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> File Checker-how To Check File Whith Html Through Html?
mahirharoon
post Dec 15 2007, 02:27 PM
Post #1


Advanced Member
*******

Group: Members
Posts: 102
Joined: 25-November 07
Member No.: 53,695



edit:sorry for the mistake it is php not html
and its with not whith
my code checking script=
CODE
<?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
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

This post has been edited by mahirharoon: Dec 15 2007, 02:32 PM
Go to the top of the page
 
+Quote Post
galexcd
post Dec 18 2007, 02:40 AM
Post #2


Define:EVIL PROGRAMMER (ē'vəl prō'grăm'ər)- n. An organism that converts caffeine into evil software.
***********

Group: [HOSTED]
Posts: 1,074
Joined: 25-September 05
From: Los Angeles, California
Member No.: 12,251



You can tell php to hide errors such as this if you put an at symbol (@) before the function returning the error.
i.e.
CODE
if(@file_exists($filename)){
Go to the top of the page
 
+Quote Post
mahirharoon
post Dec 22 2007, 06:59 AM
Post #3


Advanced Member
*******

Group: Members
Posts: 102
Joined: 25-November 07
Member No.: 53,695



thanks alex the programmer
i used it for my project
CODE
<?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

This post has been edited by mahirharoon: Dec 22 2007, 07:06 AM
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Getting List Of Directories And Files Using Php(6)
  2. Script: Php Jukebox(4)
  3. I Need Help With File Edit In Php(6)
  4. Include File.php?id=something(13)
  5. Adapting Html Code Embed To Work On Phpnuke(7)
  6. File In Database(1)
  7. File Format Unknown! (wap)(6)
  8. Display Random File In A Directory(9)
  9. Help Needed With Directory/file Listing Code Infinite Loop(5)
  10. Help Php: How To Load String From Text File (solved)(9)
  11. Php Help Needed Including File In A Page.(2)
  12. Help With Moving Html Form Results To Shopping Cart?(3)
  13. Edit .txt File In Ftp Via Webpage(2)
  14. [php]simple Flat File Text Manipulator(3)
  15. <?php ?> Marking Up With Php(0)
  1. <?php ?> Unique Visitors Script(2)
  2. File Upload(1)
  3. No File Extension(3)
  4. Php And Flash Image Gallery(5)
  5. Script To Translate Into Bbcode From Html Tags(1)
  6. Html Site With Login(2)
  7. Html Code Tester. Online Script(15)
  8. Updating Php File Through A Web Form(5)
  9. How Do I Get The Result To "stick" And Add Html Tags?(14)
  10. Need Some Help In File Browser(8)
  11. Php Configuration File(16)
  12. Html Form!(4)
  13. Linux/ Apache /mod_rewrite Issue(4)


 



- Lo-Fi Version Time is now: 13th October 2008 - 12:43 AM