Need Help with PHP - config Solved

User's avatar
David M.
06:21 Jun 05, 2014
I have an odd set up that supports multiple image upload directories. For example I have multiple directories like so:
zenbinder.com/user1/assets/
zenbinder.com/user2/assets/
zenbinder.com/user3/assets/
zenbinder.com/user4/assets/

So when a user uploads an image it needs to go into "it's" correct ASSETS directory

See my screen shot. The user id is pulled from the URL in a GET call and it is in a variable names $userid

my ckEditor and doksoft items are here:
zenbinder.com/_admin/ckeditor/plugins/doksoft_uploader/
zenbinder.com/_admin/ckeditor/plugins/doksoft_image/

I believe my issues are in lines 10 and 18

Please help
 screen_doksoft.png   23.2 KB
Support team avatar
JS+
18:00 Jun 05, 2014
Hello,

I see the problem in using `dirname` function. It does not return ending shash, so your notation must be:
dirname(__FILE__).'/'.$userid.'/assets/'

BUT note that `dirname(__FILE__)` returnes a directory from current file despite your upload folders are inside site's root. If you have no special URL router (rewrite module's options) I recommend you to use absolute path from disc's root ('/') as a string instead of this function.
User's avatar
David M.
18:30 Jun 05, 2014

I used absolute URLS in both places. And I get an error dialogue. See code on lines 10 and 20. Plus I captured the error message.

Thanks for your help - I think we are close?


 error2.png   29.1 KB
User's avatar
David M.
18:50 Jun 05, 2014
In my Googling, it appears this could be a php config issue?
User's avatar
David M.
19:10 Jun 05, 2014
Also note that I tried these combinations in line 10:
$config = 'www.zenbinder.com/_admin/ckeditor/plugins/doksoft_uploader/';$config = 'www.zenbinder.com/_admin/ckeditor/plugin..._uploader/userfiles/';
User's avatar
David M.
00:38 Jun 06, 2014
But on line 20 that should be a directory path not an URL.
So it should look something like: /var/www/zendbinder/ . $userid . /assets

I got this from my host:
$config = '/var/www/vhosts/zenbinder.com/httpdocs/'.$userid.'/assets/';

So I feel confidant that the URLs are correct.

Still get a HTTP ERROR message?

Could it be the htaccess or some php setting?
User's avatar
David M.
07:02 Jun 06, 2014
SOLUTION THAT WORKS in my case:

I will post this so that others may be helped if they have a similar issue.

My line 10 needed to be:
$config = '/'.$userid.'/assets/';

My line 20 needed to be:
$config = '/var/www/vhosts/MyDomainNameHere.com/httpdocs/'.$userid.'/assets/';

One problem was that the variable $userid was NOT being recognized, so my developer had to create a session:

THIS WAS PLACED AT THE TOP IN THE upload.php file:
$userid = $_GET;require_once('config.php');

THIS WAS PLACED IN THE config.php file:
session_start();$userid = $_SESSION;

The users was put into a variable by being pulled from the url:
http://www.mydominnamehere.com/_admin/index.php?pg=editpost&user=lwc&id=8181

(REPLACE the MyDominNameHere.com with your domain of course :-)

This solution places the images in the whatever user asset directory is using it. for example:

If user is "user1", then the files are placed in the "user1/assets" directory
If user is "user2", then the files are placed in the "user2/assets" directory
If user is "billygoat", then the files are placed in the "billygoat/assets" directory

I hope this helps future users… David (LC4D.org)
Support team avatar
JS+
18:25 Jun 06, 2014
baseURL is URL, it is correct.
But baseDir is directory, not URL. For example:
$config['baseDir'] = '/var/www/yoursite/'.$assetId.'/assets';

Good to hear that you have fugured out your problem.