Thenewphp
09-18-2011, 11:05 AM
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, 12:17 PM
Hi Thenewphp
its file_exists()
with and s
just to be clear its 'exists' not 'exist' ;)
Thenewphp
09-18-2011, 01: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, 03: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, 03: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).