• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Uploading .doc files doesn't work

#1
[eluser]4myGod[/eluser]
I'm getting the following error when I try to upload:

"The filetype you are attempting to upload is not allowed.".

Here is my mime for .doc:

'doc' => array('application/msword','application/doc','appl/text','application/vnd.msword','application/word','application/winword','application/vnd.ms-word','application/x-msw6','application/x-msword'),

As you can see I already tried to make up for it by adding more mimes. I have no idea what the problem can be... the file is .doc.

Here is my code:

Code:
$sntError = $this->uploadFile($id,'notes','doc|pdf|docx');

private function uploadFile ($id,$input,$extensions) {
$this->load->library('upload');
$config['allowed_types'] = $extensions;
$config['upload_path'] = './upload/sermon/'. $input;
$config['file_name'] = $input .'-'. $id;
$config['max_size'] = '10000';
$config['overwrite'] = true;
$this->upload->initialize($config);
$uploaded = $this->upload->do_upload($input);
  
$errors = $this->upload->display_errors('<div class="error">', '</div>');
  
if (!$errors && $uploaded) {
  $fileData = $this->upload->data();
  $this->saveSermonAttachments($id,$input,$fileData['file_name']);
} else {
  return $errors;
}
}

#2
[eluser]Rodrigo Alexandre[/eluser]
try:

Code:
$config['allowed_types'] = 'doc|docx|pdf';
for example!

#3
[eluser]4myGod[/eluser]
I tried coding that in, in your order, and it still didn't work. But that's pretty much already what I had. It has the same error.

#4
[eluser]InsiteFX[/eluser]
Check your ./application/config/mimes.php
Code:
'pdf'  => 'application/pdf',
'doc'  => 'application/msword',
'docx' => 'application/msword',
'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml',
'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml',
'docm' => 'application/vnd.ms-word',
'dotm' => 'application/vnd.ms-word',

#5
[eluser]4myGod[/eluser]
I did print_r($fileData); to figure out what the .doc file_type was. It was "text/plain," so I added that to my mimes.php and it solved my problem.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.