Leoh
Leoh

Reputation: 670

how to enable cakephp media plugin to upload pdf files and docs

I apply the media plugin in my project but this is only for jpeg and png.. you can see in the demo... demo

There is a validation that allow pdf files but doesnt work. in attachment.php

 var $validate = array(
    'file' => array(
        'resource'   => array('rule' => 'checkResource'),
        'access'     => array('rule' => 'checkAccess'),
        'location'   => array('rule' => array('checkLocation', array(
            MEDIA_TRANSFER, '/tmp/'
        ))),
        'permission' => array('rule' => array('checkPermission', '*')),
        'size'       => array('rule' => array('checkSize', '5M')),
        'pixels'     => array('rule' => array('checkPixels', '1600x1600')),
        'extension'  => array('rule' => array('checkExtension', false,
         array(
            'jpg', 'jpeg', 'png', 'tif', 'tiff', 'gif', 'pdf', 'tmp'
        ))),
        'mimeType'   => array('rule' => array('checkMimeType', false, array(
            'image/jpeg', 'image/png', 'image/tiff', 'image/gif',
      'application/pdf'
    )))),
    'alternative' => array(
        'rule'       => 'checkRepresent',
        'on'         => 'create',
        'required'   => false,
        'allowEmpty' => true,
    ));

this is the default configuration but doesnt work for pdf files only for images.

Upvotes: 1

Views: 1412

Answers (1)

Suman
Suman

Reputation: 9561

If you are using CakePHP 2.x, I would recommend the AjaxMultiUpload plugin which should take care of this for you: http://bakery.cakephp.org/articles/srs2012/2012/03/12/ajaxmultiupload_plugin_for_cake_2_0_x_and_2_1

Upvotes: 1

Related Questions