Cant seem to make php move_uploaded_file function to work.
$MAX_FILESIZE = 5 * 1024 * 1024;
$rEFileTypes = "/^\.(jpg|jpeg|gif|png|pdf|xls|xlsx|ppt|pptx){1}$/i";
$isFile = is_uploaded_file($_FILES["prodImage"]["tmp_name"]);
if($isFile)
{
echo "inside first if";
$safe_filename = preg_replace(array("/\s+/", "/[^-\.\w]+/"), array("_", ""), trim($_FILES["prodImage"]["name"]));
if($_FILES["prodImage"]["size"] <= $MAX_FILESIZE && preg_match($rEFileTypes, strrchr($safe_filename, '.')))
{
echo "inside second if";
$isMove = move_uploaded_file($_FILES["prodImage"]["tmp_name"], $to);
if($isMove)
{
echo "Uploaded Succesfully";
}
}
else
{
echo "image is too big";
}
}
else
{
echo "nuthing mega";
}
Can someone tell me why first condition always fails? I have a file type in a form with a name 'prodImage' and i specified correctly the enctype.