...

View Full Version : Resolved need help with file_exist



Thenewphp
09-18-2011, 12:05 PM
Gettin this error: Fatal error: Call to undefined function file_exist() in C:\xampp\htdocs\series\script\page2.php on line 5

With this:


<?php

$filename = 'files.txt';

if (file_exist($filename)) {
echo 'File already exist. ';
} else {
$handle = fopen($filename, 'w');
fwrite($handle, 'welcome man');
fclose($handle);
}

thesam101
09-18-2011, 01:17 PM
Hi Thenewphp

its file_exists()

with and s

just to be clear its 'exists' not 'exist' ;)

Thenewphp
09-18-2011, 02:26 PM
am getting this error help me :

Notice: Undefined index: file in C:\xampp\htdocs\series\script\page2.php on line 2

Notice: Undefined index: file in C:\xampp\htdocs\series\script\page2.php on line 6

with this code :

<?php
$name = $_FILES['file']['name'];
//$size = $_FILES['file']['size'];
//$type = $_FILES['file']['type'];

$tmp_name = $_FILES['file']['tmp_name'];
if (isset($name)) {
if(!empty($name)) {
echo 'OK.!!';

} else {
echo 'Please choose a file';

}
}


?>
<form action="page2.php" method="POST" enctype="multipart/form-data">
<input type="file" name="file"><br /><br />
<input type="submit" value="Submit">
</form>

thesam101
09-18-2011, 04:25 PM
Hi again Thenewphp

When are you getting that error? Before you submit the form? Or after? or Both?

There will be nothing in $_FILES until after you submit the form.

BluePanther
09-18-2011, 04:41 PM
@thesam101: Thenewphp also started a new thread for this new problem, and it got resolved in that thread. He wasn't checking for the $_FILES isset() (basically what you've just said).



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum