I was trying to make an image upload script but $_files['photo']; is empty all the way.
$_FILES['photo']['name'];
$_FILES['photo']['size'];
$_FILES['photo']['type'];
$_FILES['photo']['tmp_name'];
$_FILES['photo']['error'];
When I echo them out, they all return absolutely nothing.
if($_FILES['photo']['name'])
{
if(!$_FILES['photo']['error'])
{
$new_file_name = strtolower($_FILES['photo']['name']);
if($_FILES['photo']['size'] > (1024000))
{
$valid_file = false;
$msg = 'Oops! Your file\'s size is to large.';
echo $msg;
}
if($valid_file)
{
move_uploaded_file($_FILES['photo']['tmp_name'], 'images/thumbnails/'.$new_file_name);
$msg = 'Congratulations! Your file was accepted.';
echo $msg;
}
}
else
{
$msg = 'Ooops! Your upload triggered the following error: '.$_FILES['photo']['error'];
echo $msg;
}
}
Did I do something wrong maybe?
<form action='?p=post' method='POST'>
<input type='file' name='photo' size='25' />
<input type='submit' value='Posten' name='submit' /><br />
</form>
Your form is missing an essential part => enctype="multipart/form-data"
add it in your form.
<form action='?p=post' method='POST' enctype='multipart/form-data'>
Consult: