CodeIgniter Forums

Full Version: How to manage example.com website from admin.example.com
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey, 
I'd like to ask if it's possible to manage files, folders etc. of the main domain (example.com) from subdomain (e.g.: admin.example.com).

I want to create (folders, upload files etc.) in the main domain but i can't while i get a 505 error.

Have you faced anything like that? How did you solve it?

Thanks!
That's a strange server response. What exactly are you doing to produce that?
(11-15-2018, 04:28 PM)dave friend Wrote: [ -> ]That's a strange server response. What exactly are you doing to produce that?

It's something like a blog. But i placed the main site in "example.com" and the admin panel in "admin.example.com".

What i also want is to be able to manage the files from subdomain.
Is that possible?
Yes, it should be possible. (Did you post this question on Stack Overflow too? I have a suggestion there.)

But what's happening to cause a 505? That response means HTTP VERSION NOT SUPPORTED so I'd take a close look at any special headers you're setting.
(11-15-2018, 06:50 PM)dave friend Wrote: [ -> ]Yes, it should be possible. (Did you post this question on Stack Overflow too? I have a suggestion there.)

But what's happening to cause a 505? That response means HTTP VERSION NOT SUPPORTED so I'd take a close look at any special headers you're setting.

No i've not posted something on stack overflow! Every issue related to codeigniter is suddenly unknown for them! Let's not talk about it!!  Big Grin Big Grin

I think that it's something related to the config of the image upload. Here's the part of the "Posts" controller where i set the config for the image upload:

Code:
$post_id = random_string('numeric', 7);
$dir_exist = false;
if( !is_dir('../../htdocs/assets/img/posts' . $post_id) ){
 mkdir('../../petvres/assets/img/posts' . $post_id, 0777, true);
$dir_exist = true;
}
if (!empty($_FILES['mainImg']['name'])) {
$config = array(
 'upload_path' => '../../htdocs/assets/img/posts/' . $post_id,
 'encrypt_name' => TRUE,
 'allowed_types' => 'gif|jpg|jpeg|png',
 'max_size' => '1310720',
 'max_width' => '2048',
 'max_height' => '2048'
);
$img_data = array();
$this->load->library('upload', $config);

...
(the rest of the controller code)


I think there's something wrong with the upload_path.
Could it be that first, you see if the path '../../htdocs/assets/img/posts ...'; exists
and if it does not  you create a directory ../../petvres/assets/img/posts'  
But then you move forward with the first one as your upload directory.

Which seem like some part of that must be a mistake, but there is much code you don't show meaning I don't understand all I know.

I'm confused by what you're attempting to check with the path '../../htdocs/assets/img/posts' . $post_id. That relative path is not required.
As far as the server is concerned the main script executing is index.php. So, unless your code has called chdir('/some/dir/);  the current working directory is 'htdocs'. So I think what you really want is
PHP Code:
if( !is_dir('./assets/img/posts' $post_id) ){ 


I don't see where you use $dir_exist but consider setting it like this
PHP Code:
$dir_exist mkdir('/what/ever/it/is/really/supposed/to/" . "$be:, 0777, true); 


and I don't think any of this would cause a 505 server response.