Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

$_FILES as undefined index

$
0
0

Hi, I'm trying to create an upload script for just .doc, .docx, and .pdf files

 

I'm getting an Notice: Undefined index: file in /Users/pat/Sites/recruitment/RecruitSmart/upload/uploader.php on line 7 for each time I use $_FILES ?

$path = "CV/".$_FILES['file']['name'];
$allowedExts = array("pdf", "doc", "docx");
$extension = end(explode(".", $_FILES["file"]["name"]));
if (($_FILES["file"]["type"] == "application/pdf") || ($_FILES["file"]["type"] == "application/msword") || ($_FILES["file"]["type"] == "application/vnd.openxmlformats-officedocument.wordprocessingml.document") && ($_FILES["file"]["size"] < 20000000) && in_array($extension, $allowedExts))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Error";
}
else
{
copy($_FILES['file']['tmp_name'], $path);
echo "Success";
}
}
else
{
echo "Wrong file type";
}

Viewing all articles
Browse latest Browse all 13200

Trending Articles