Welcome Guest, Not a member yet? Register   Sign In
Upload class will not allow docx files to be uploaded
#1

[eluser]jvk22[/eluser]
I can't get the upload class to allow docx files to be uploaded (I fixed the docx problem). I've tried changing the mime types in mimes.php but I still get an error
"The filetype you are attempting to upload is not allowed."

Code:
'docx' => array('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'text/plain'),



Code:
public function upload_file($team_id)
{
  $dir = $this->get_team_dir($team_id) . $this->get_photo_dir($team_id);
  
  $config['upload_path'] = $dir;
  $config['allowed_types'] = 'rtf|docx|doc|txt|pdf|xls';
  $config['max_size'] = '10000000000';
  $config['encrypt_name'] = true;


  $this->load->library('upload', $config);

  if ( ! $this->upload->do_upload())
  {
   return array('error'=>true, 'message'=>$this->upload->display_errors());

  
  }
  else
  {

   $arr = array('error'=>false, 'message'=>$this->upload->data());

   return $arr;

  }
#2

[eluser]john_j[/eluser]
In your mimes.php did you add it as "text/plain"??
#3

[eluser]jvk22[/eluser]
Yes I did but for some reason the codeigniter upload library was reading the mime type a application/zip so I added that to the mime type for docx and that did the trick.
#4

[eluser]Unknown[/eluser]
Set docx mime as array and add msword to it:
'docx' => array('application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document')
#5

[eluser]beaudierman[/eluser]
[quote author="Vitaly Mironenko" date="1366009063"]Set docx mime as array and add msword to it:
'docx' => array('application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document')[/quote]

Thank you for posting this, I was just having this issue. I found that adding 'application/msword' worked for docx files saved by Windows, but for some reason files saved on Word for Mac weren't working. My solution was to add 'application/zip' as well.

Code:
'docx' => array('application/msword', 'application/zip', 'application/octet-stream', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'),




Theme © iAndrew 2016 - Forum software by © MyBB