too long

I have a functionality where user will send documents without storing anything in the database. So there is no field to put in models. Once it is uploaded, it directly sends that document as attachment in the email.

All the links found on Stackoverflow requires 'models' for that controller for file validation. So, this is NOT a duplicate.

Can you please advice on how to directly send validated files (through mime types and size) before send an email?

Thanks.

If you are using CakePHP 2.1

File Class

#info

Returns the File info as an array with the following keys:

  • dirname
  • basename
  • extension
  • filename
  • filesize
  • mime

Validation Class

#mimeType

#maxLength

#minLength

Notes:

  • File Class is not present on CakePHP 1.x
  • I am not sure if you can use this class with a tmp file. Test it. If you can't, save it to a folder and call the class.