I want to upload images on my site using a form. I created a folder, uploads to store all the images.
The code is as follows:
<?php
if($_POST['upload'])
{
edit
$maxwidth = 250;
$maxheight = 250;
$max_filesize = 102400;
$uploads = '/uploads';
$types_array = array('image/gif','image/pjpeg','image/x-png');
end edit
if($_FILES['image']['name'] == "")
{
echo "Please select a file to upload!\n";
exit;
}
if(!in_array($_FILES['image']['type'], $types_array))
{
echo "That file type is not allowed!\n";
exit;
}
$max_filesize_kb = ($max_filesize / 1024);
if($_FILES['image']['size'] > $max_filesize)
{
echo "You file is too large, files may be up to ".$max_filesize_kb."kb\n";
exit;
}
$imagesize = getimagesize($_FILES['image']['tmp_name']);
$imagewidth = $imagesize[0];
$imageheight = $imagesize[1];
if($imagewidth > $maxwidth || $imageheight > $maxheight)
{
echo "You file is too large, files may be up to ".$maxwidth."px x ".$maxheight."px in size\n";
exit;
}
move_uploaded_file($FILES['image']['tmp_name'], $uploads.'/'.$FILES['image']['name']) //error
or die ("Couldn't upload ".$_FILES['image']['name']."\n");
}
?>
It gives me an error at the move_uploaded_file(). I can't understand why. Plz help me get out. Thanks