This repository was archived by the owner on May 25, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
CakePHP Setup for Ver. 2.*.*
Ankit Pokhrel edited this page Aug 31, 2014
·
2 revisions
- Place
UploadHandler.php
invendor/file.upload
. You can use any name instead offile.upload
. - Have jQuery setup in your app.
- Copy jQuery File Upload files in the proper directories of your Cake app, usually
webroot/js
. - You can now initialize jQuery-File-Upload options in your controller using following way.
App::import('Vendor', 'UploadHandler', array('file' => 'file.upload/UploadHandler.php'));
$options = array(
'upload_dir' => 'Your upload directory',
'accept_file_types' => '/\.(gif|jpe?g|png)$/i'
);
$upload_handler = new UploadHandler($options);
You can change the upload folder in CakePHP by simply attaching the upload behavior and passing path in the upload settings. Use these lines just before saving the data.
$this->User->Behaviors->attach('Upload');
$this->User->uploadSettings('profile_pic', 'path', 'Your new upload path');