sunhater / kcfinder

KCFinder web file manager
http://kcfinder.sunhater.com
402 stars 209 forks source link

An uploadURL having a relative path will fail when kcfinder is run from an alias path #149

Open ghost opened 7 years ago

ghost commented 7 years ago

Version 3.12

uploader.php line 237 re-assigns the value of the uploadURL after calling the helper rel2abs_url with a relative url path.

However, when kcfinder is run from an Apache HTTPD alias path, rel2abs_url fails to determine the absolute path of the url. helper_path.php line 35 returns false due to this condition.

The false value is then assigned to the uploadURL configuration, and kcfinder is unable to return a valid file URL to the client.

This is regrettable, because in my situation, the uploadURL originally set was valid and correct. No conversion to an absolute URL should have been necessary, near as I can tell.

The only way to use the uploadURL when kcfinder runs from an alias path is to start the URL with a slash ("/") or use a full url with all components specified.

ghost commented 7 years ago

Converting the relative URL to an absolute URL creates problems for the CKEditor client. The client is configured with a baseHref and expects a relative URL to be returned by the browser. This rel2abs_url function is causing the url returned by the browser to be non-relative and the baseHref cannot properly applied by the CKEditor.

I don't understand why its necessary to fiddle with a configuration option that was specified by the user. I am temped to rewrite this function to do nothing and return the original path as a solution to the immediate problem.

webcatUK commented 7 years ago

Hi! Converting the relative URL has caused a cascade of issues (I'm using it with a Smarty template system) so I have had to admit defeat and revert back, however the number of error messages from the functions within the 'browse server' makes it appear really substandard for any user, so a fix for this would be fantastic, either that or how do I remove the things triggering the errors: refresh button, delete, rename, download, change from thumbnail view to list (and back) etc.. I would be happy now just to take those off and minimise the errors a user might encounter. Ive been struggling for two days and have reached the end of my own limited abilities to change coding!

ghost commented 7 years ago

The cleanest solution for me was to stop using a relative URL and instead, use a URL that started with a slash ("/"). It works fine with an alias path that way, and I didn't have to modify the code. A little irritating though and nothing is documented about it.

webcatUK commented 7 years ago

I tried that and now all those error messages are gone and every function is operating correctly - and all the images thumbnails have also appeared, whoohoo! So thank you VERY much for your comment, you're a star 👍