1

My filemanager folder is located here:

localhost/cakeapp/app/webroot/js/tinymce/js/tinymce/plugins/filemanager/

In cakeapp root directory, I have two folders:

uploadedImages (cakeapp/uploadedImages)
UploadedImagesThumbs (cakeapp/uploadedImagesThumbs).

I have this situation in config.php File:

$base_url ="http://localhost";

// path from base_url to base of upload folder (with start and final /)
$upload_dir = '/cakeapp/uploadedImages/';

// relative path from filemanager folder to thumbs folder (with final /)
$thumbs_base_path = '???????/uploadedImagesThumbs'; 

// relative path from filemanager folder to upload folder (with final /)
$current_path = '???????/uploadedImages/'; 

How I get the correct relative path for $thumbs_base_path and $current_path from filemanager folder?

Kevin
  • 41,694
  • 12
  • 53
  • 70
michael24B
  • 293
  • 1
  • 6
  • 20

1 Answers1

0

You could try something like

function getRelativePath($from, $to) {
$patha = explode('/', $from);
$pathb = explode('/', $to);
$start_point = count(array_intersect($patha,$pathb));
while($start_point--) {
    array_shift($patha);
    array_shift($pathb);
}
$output = "";
if(($back_count = count($patha))) {
    while($back_count--) {
        $output .= "../";
    }
} else {
    $output .= './';
}
return $output . implode('/', $pathb);
}

Check the source.It has many more examples

Community
  • 1
  • 1
Avinash Babu
  • 6,171
  • 3
  • 21
  • 26