simialbi / yii2-elfinder

This extension integrates the jQuery elFinder into yii2 framework
MIT License
7 stars 5 forks source link

Unable to set URL under connectionSets #3

Closed ghost closed 4 years ago

ghost commented 4 years ago
 'connectionSets' => [
                'default' => [ // like elfinder roots
                    [
                        'class' => 'simialbi\yii2\elfinder\ElFinderConfigurationLocalFileSystem',
                        'path'  => '@webroot/uploads',
                        'URL'   => '@web/file/files'
                    ]
                ]
            ],

This is how I have defined URL 'URL' => '@web/file/files' where file is my controller and files is my action . Could you please let me know how exactly this URL show be passed in yii2 basic template .

127.0.0.1:8080/project/elfinder/proxy/index?baseUrl=QHdlYi9maWxlL2ZpbGVz&path=/NewFolder/file_example_PNG_500kB.png&_t=1587811929

simialbi commented 4 years ago

The Module automatically rewrites your URL by one used via ProxyController here: https://github.com/simialbi/yii2-elfinder/blob/master/Module.php#L129 This guarantees always working URLs on all systems with no encoding problems or strange filenames behaviors. If I understand correctly: what you'd like to do is use without this proxy controller?

ghost commented 4 years ago

Thanks for the response .Url manager helped me in this scenario . Really appreciate your work .
This is how I resolved it .

    'urlManager' => [
  'controller/action/<file:.*>' => 'controller/action',
]
public function actionYourActionName($file)
    {
        $image_path = YOUR_UPLOAD_PATH . basename($file);
        if (file_exists($image_path)) {
            return \yii::$app->response->sendFile($image_path, $file, [
                'inline' => true //OPTIONAL
            ]);
        } 
         return "What exception you want to throw";
    }
simialbi commented 4 years ago

I'm glad to hear you could solve it yourself. Thx 4 the post of your solution