01-31-2008, 02:21 AM
[eluser]sherpa[/eluser]
Hi Everybody. I want to share my problem here. My problem is that i can't upload PDF files. I have created a function which meants to upload as many PDF files as i want passing file arrays and filepath arrays to the function as parameters. Everytime I try, it says The filetype you are attempting to upload is not allowed. However, i can upload JPG and GIF files with the same code changing extension without any errors. I don't know whats wrong with my following code. Hope you guys help me..;
Hi Everybody. I want to share my problem here. My problem is that i can't upload PDF files. I have created a function which meants to upload as many PDF files as i want passing file arrays and filepath arrays to the function as parameters. Everytime I try, it says The filetype you are attempting to upload is not allowed. However, i can upload JPG and GIF files with the same code changing extension without any errors. I don't know whats wrong with my following code. Hope you guys help me..;
Code:
class Post extends Controller
{
function Post()
{
parent::Controller();
}
function product()
{
if(isset($_FILES['pdf']) AND strlen($_FILES['pdf']['name'])>0)
{
$pdf_path = array('./pixs/products/pdf');
$pdf_files = array('pdf'); // FILE INPUT NAME
$PDFUpload = $this -> UploadPDF($pdf_path, $pdf_files)
}
}
function UploadPDF($upload_path=array(),$files=array())
{
$config['allowed_types']= 'pdf';
$pdfPath[] = array();
$data[] = array();
$count_files = count($files);
for($i = 0; $i < $count_files; $i++)
{
$config['upload_path'] = $upload_path[$i];
$this -> load -> library('upload',$config);
if(isset($files[$i]) || is_array($files[$i]))
{
if(!$this -> upload -> do_upload($files[$i]))
{
echo $this->upload->display_errors('<p>', '</p>');
}
else
{
$data[$i] = array('upload_data' => $this->upload->data());
$pdfPath[$i] = $data[$i]['upload_data']['full_path'];
return $pdfPath;
}
}
}
return FALSE;
}
}