Possible Duplicate:
Undefined index: file
Hi I’m learning right now how to upload images to database, but I’m getting this error/notice
Notice: Undefined index: image in C:\xampp\htdocs\Pildibaas\index.php on line 19
Here is my index.php whole code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Image upload</title>
</head>
<body>
<form action="index.php" method="POST" enctype="multipart/form-data">
File:
<input type="file" name="image"> <input type="submit" value="Upload">
</form>
<?php
mysql_connect ("localhost", "root", "") or die (mysql_error());
mysql_select_db ("databaseimage") or die (mysql_error());
?>
</body>
</html>
Line 19 (this line gives error) cut out from index.php:
echo $file = $_FILES['image']['tmp_name'];
From google found that i need to change premission of tmp folder, but it allready shoud have all premissions it needs.
In tutorial he dont get this error
thank you
should be
This checks first if
$_FILES['image']is set. If not, this wil not be run. Therefore, you will not have an error that it is out of index.Because you first have to submit the form before
$_FILES['image']will be set…Also, the input tag is self closing, so your form will not be:
but: