PHP - Undefined index error
Posted
by
user1815290
on Stack Overflow
See other posts from Stack Overflow
or by user1815290
Published on 2012-11-10T22:54:06Z
Indexed on
2012/11/10
23:00 UTC
Read the original article
Hit count: 119
php
This is my form with a file input field named "photo":
<form action = "spremi-film.php" method = "POST" enctype = "multipart/form-data">
<div class="grid_2">Naslov:</div>
<div class="grid_10"><input type="text" name="naslov" value="" /></div>
<div class="grid_2">Žanr: </div>
<div class="grid_10"><?php izborZanra(); ?></div>
<div class="grid_2">Godina: </div>
<div class="grid_10"><?php izborGodine(); ?></div>
<div class="grid_2">Trajanje:</div>
<div class="grid_10"><input type="text" name="trajanje" value="" /></div>
<div class="grid_2">Izbor slike:</div>
<!--<input type="hidden" name="MAX_FILE_SIZE" value="30000" />-->
<div class="grid_10"><input type="file" name="photo" /></div>
<div class="grid_12"><input type="submit" value="SPREMI" /></div>
</form>
After that i put this code:
$uploaddir = '/slike';
$uploadfile = $uploaddir . basename($_FILES['photo']['name']);
//echo '<pre>';
if(move_uploaded_file($_FILES['photo']['tmp_name'], $uploadfile))
{
echo 'Slika je uspješno spremljena!';
}
else
{
echo 'Slika nije spremljena!';
}
//print_r($_FILES);
//echo '</pre>';
When i run this i have an undefined index: photo notice in my browser. Help, please.
© Stack Overflow or respective owner