...

View Full Version : need help with code



Thenewphp
09-18-2011, 01:44 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>

abduraooft
09-18-2011, 02:04 PM
Try

<?php
if(isset($_FILES['file'])){
$name = $_FILES['file']['name'];
//$size = $_FILES['file']['size'];
//$type = $_FILES['file']['type'];

$tmp_name = $_FILES['file']['tmp_name'];

if(!empty($name)) {
echo 'OK.!!';

} else {
echo 'Please choose a file';

}
}
?>

BluePanther
09-18-2011, 02:04 PM
Show us more of the code. The error means there's no index 'file' in the $_FILES array. There could be multiple reasons for this, but we wont know for sure until we see the full code.

Thenewphp
09-18-2011, 02:11 PM
Thank you very much man



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum