Forms Module File Attachments

embemb
edited May 2017 in Modules
Hi

I've built a form using the forms module that has an option to attach a file. In my config I have set it to allow doc, docx and pdf as per below, however only PDFs ever come through attached to an email.

$config['forms']['attach_file_params'] = array(
'upload_path' => APPPATH.'cache/',
'allowed_types' => 'pdf|doc|docx',
'max_size' => '1000',
);

I've tried changing the path to one in my assests folder that is set to allow all the above file types but it is still not working. It only seems to want to write PDFs to the temporary folder and therefore that is all I get attached to messages. Any Ideas?

Thanks

Comments

  • edited 8:23AM
    Is PDF on your list of supported files in your apache config?
  • embemb
    edited 8:23AM
    I will double check, I'm not sure it will be a server config issue though as I can upload doc and docx using the file manager in fuel admin.
  • edited 8:23AM
    I would start putting some debug code in the fuel/modules/forms/Fuel_forms.php file around line 968 to see what the actual $params values are and whether or not there are any upload errors. So around this line of code:
    if ( ! $this->CI->upload->do_upload($key)) { $error = array('error' => $this->CI->upload->display_errors()); $this->_add_error($error); } else { $this->upload_data[$key] = $this->CI->upload->data(); }
  • embemb
    edited 8:23AM
    Humm well I get an upload error that the file type is not allowed however the params are getting through and doc and docx are in the allowed types. I'll speak to my webhost and see if there is anything in the server config that could be blocking them.
  • embemb
    edited 8:23AM
    I've just created a simple PHP upload script and all is good with doc and docx so I will continue looking to see if I can find what ever it is that is blocking them.
  • edited 8:23AM
    FUEL uses the Upload class and sometimes the mimetypes need to be updated to support the files being uploaded. Specifically, you may want to look at the Upload::is_allowed_filetype() method to see if the mime is supported.
  • embemb
    edited 8:23AM
    It was a mime issue. We are running 1.3.2 in this instance. I took the mime array from version 1.4.1 and put it in /fuel/application/config/mimes.php and the issue was resolved. The doc and docx entries are slightly different between the two. Thanks for all the pointers along the way.
Sign In or Register to comment.