[eluser]sazet_rey[/eluser]
Hii Friends, I am creating a send mail application, so for attaching files to mails, i first need to upload the files to the server folder and then i need to attach them.
my problem is that i am using a mutiple file upload application to first upload the files to the server folder.
here's my uploading code
foreach($_FILES['a_file']['tmp_name'] as $key=>$val)
{
echo $_FILES["a_file"]["type"][$key];
if(($_FILES["a_file"]["type"][$key] == "image/gif")
|| ($_FILES["a_file"]["type"][$key] == "image/png")
|| ($_FILES["a_file"]["type"][$key] == "image/GIF")
|| ($_FILES["a_file"]["type"][$key] == "image/PNG")
|| ($_FILES["a_file"]["type"][$key] == "image/jpeg")
|| ($_FILES["a_file"]["type"][$key] == "image/jpg")
|| ($_FILES["a_file"]["type"][$key] == "image/JPG")
|| ($_FILES["a_file"]["type"][$key] == "image/JPEG")
|| ($_FILES["a_file"]["type"][$key] == "image/pjpeg")
|| ($_FILES["a_file"]["type"][$key] == "text/plain")
|| ($_FILES["a_file"]["type"][$key] == "image/pjpeg")
|| ($_FILES["a_file"]["type"][$key] == "application/octet-stream")
|| ($_FILES["a_file"]["type"][$key] == "application/vnd.openxmlformats-officedocument.wordprocessingml.document")
|| ($_FILES["a_file"]["type"][$key] == "application/msword")
|| ($_FILES["a_file"]["type"][$key] == "application/zip")
|| ($_FILES["a_file"]["type"][$key] == "application/rar")
|| ($_FILES["a_file"]["type"][$key] == "application/x-rar")
)
{
$file= 'attachment/'.md5(uniqid(rand())).$_FILES['a_file']['name'][$key];
$files="./".$file;
move_uploaded_file($val,$files);
$fullpath= base_url().$file;
}
else
{
echo "not uploaded";
}
}
My problem is that the application is working fine for other files like .zip, .jpg, .mpeg, etc. But its not working for the .pdf and .rar extension.
I have even added these two lines to the mimes.php in config folder of the codeigniter, but still no luck.
'rar' => array('application/rar', 'application/x-rar', 'application/x-rar-compressed', 'application/x-compressed', 'application/octet-stream')
'pdf' => array('application/pdf', 'application/x-download')
can anybody help me out of this problem.
the error which displays when i try to upload .rar or .pdf files is given below
A PHP Error was encountered
Severity: Notice
Message: Undefined index: a_file
Filename: controllers/mail.php
Line Number: 32