nenad-zivkovic / yii2-advanced-template

Yii2 improved advanced application template that can bake you cookies
BSD 3-Clause "New" or "Revised" License
93 stars 66 forks source link

What alias can I use within module configurations when trying to set the path to outside the _protected directory #16

Closed con322 closed 9 years ago

con322 commented 9 years ago

What alias can I use within module configurations when trying to set the path to outside the _protected folder for example I need to configer it so that I have an uploads folder that is accessible by both public, frontend application and backend.

_protected uploads

Here is my current config which isn't working when trying to upload/retrieve images:

'filemanager' => [
    'class' => 'pendalf89\filemanager\Module',
    // Upload routes
    'routes' => [
        // Base absolute path to web directory
        'baseUrl' => '',
        // Base web directory url
        'basePath' => '@webroot',
        // Path for uploaded files in web directory
        'uploadPath' => 'uploads',
    ],
    // Thumbnails info
    'thumbs' => [
        'small' => [
            'name' => 'Small',
            'size' => [100, 100],
        ],
        'medium' => [
            'name' => 'Medium',
            'size' => [300, 200],
        ],
        'large' => [
            'name' => 'Large',
            'size' => [500, 400],
        ],
    ],
   ],
nenad-zivkovic commented 9 years ago

In new version 2.2.0 that has just been released, you have alias @uploads that will target app_root/uploads folder that has been added to template. If you need that solution in you current project you can check new code ( see web.php config file ).

con322 commented 9 years ago

Awesome, how easy is it to update from your old version? What's th best way?

Thanks

nenad-zivkovic commented 9 years ago

Unfortunately it is not possible to do some kind of automatic update for templates. I suggest downloading new version and then copy/paste your existing code there.

con322 commented 8 years ago

Hi it doesnt seem to be working i have asked the question over at stackoverflow if you could reply on there or read on there and reply on here if possible?

http://stackoverflow.com/questions/34463684/yii2-file-manager-route-setup-for-public-uploads-folder-in-advanced-template

Thanks Connor

nenad-zivkovic commented 8 years ago

Inside _protected/common/config/bootstrap.php there is @appRoot alias defined. Try experimenting with it. Also have you tried: 'uploadPath' => '@uploads', ?

con322 commented 8 years ago

Where is the @upload defined and does @upload target the uploads folder outside the _protected folder

i get the following error when trying

'uploadPath' => '@uploads',

{"name":"PHP Warning","message":"mkdir(): Permission denied","code":2,"type":"yii\base\ErrorException","file":"/Applications/MAMP/htdocs/legit_check_new/advanced_2/_protected/vendor/pendalf89/yii2-filemanager/models/Mediafile.php","line":132,"stack-trace":["#0 [internal function]: yii\base\ErrorHandler->handleError(2, 'mkdir(): Permis...', '/Applications/M...', 132, Array)","#1 /Applications/MAMP/htdocs/legit_check_new/advanced_2/_protected/vendor/pendalf89/yii2-filemanager/models/Mediafile.php(132): mkdir('//@uploads/2015...', 511, true)","#2 /Applications/MAMP/htdocs/legit_check_new/advanced_2/_protected/vendor/pendalf89/yii2-filemanager/controllers/FileController.php(75): pendalf89\filemanager\models\Mediafile->saveUploadedFile(Array, false)","#3 [internal function]: pendalf89\filemanager\controllers\FileController->actionUpload()","#4 /Applications/MAMP/htdocs/legit_check_new/advanced_2/_protected/vendor/yiisoft/yii2/base/InlineAction.php(55): call_user_func_array(Array, Array)","#5 /Applications/MAMP/htdocs/legit_check_new/advanced_2/_protected/vendor/yiisoft/yii2/base/Controller.php(151): yii\base\InlineAction->runWithParams(Array)","#6 /Applications/MAMP/htdocs/legit_check_new/advanced_2/_protected/vendor/yiisoft/yii2/base/Module.php(455): yii\base\Controller->runAction('upload', Array)","#7 /Applications/MAMP/htdocs/legit_check_new/advanced_2/_protected/vendor/yiisoft/yii2/web/Application.php(84): yii\base\Module->runAction('filemanager/fil...', Array)","#8 /Applications/MAMP/htdocs/legit_check_new/advanced_2/_protected/vendor/yiisoft/yii2/base/Application.php(375): yii\web\Application->handleRequest(Object(yii\web\Request))","#9 /Applications/MAMP/htdocs/legit_check_new/advanced_2/backend/index.php(18): yii\base\Application->run()","#10 {main}"]}

nenad-zivkovic commented 8 years ago

Its in :_protected/common/config/main.php