Jump to content

WHMCS Storage Relative Paths Dont Work


namhost

Recommended Posts

I created a new WHMCS Storage location with address: ../../WHMCS_STORAGE/downloads

So my path structure is something like this:

  • /home/host/WHMCS_STORAGE/downloads <-- where files are stored
  • /home/host/public_html/index.php <-- where whmcs runs from
  • /home/host/public_html/admin/index.php <-- where thje admin area runs from

So, if I set ../../WHMCS_STORAGE/downloads, then I have no problems uploading files in the admin section. Because ../../ will go back two folders and reach /WHMCS_STORAGE. 

But if I open /downloads, then all hell breaks loose:

League\Flysystem\FileNotFoundException: File not found at path: putty-0.72-installer.msi in C:\xampp\htdocs\wallaby.host\public_html\vendor\league\flysystem\src\Filesystem.php:388

I assume because now it try to access ../../ and it will go back one folder too many.

I can fix this using the full direct path, but then it won't work on my local machine and on the server it is hosted. 

Is there no way I can reference this folder in a way that it will work from both /admin and /downloads? 

Link to comment
Share on other sites

ps. My temporary workaround is to set the folder to ../WHMCS_STORAGE/downloads and then tosimply copy the file from:

/home/host/public_html/WHMCS_STORAGE/downloads

to:

/home/host/WHMCS_STORAGE/downloads

I do this manually at the moment, but will see if I can use a hook to do the copying. 

Link to comment
Share on other sites

For anyone that might need it:

function check_if_downloads_folders_in_synch()
{
  $isAdminArea = true; // TODO: This can actually have an extra IF (adminArea)... to make it more sufficient.
  if ($isAdminArea)
  {
    $storageLocation1 = dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'WHMCS_STORAGE'.DIRECTORY_SEPARATOR.'downloads'.DIRECTORY_SEPARATOR;
    $storageLocation2 = dirname(__FILE__).DIRECTORY_SEPARATOR.'WHMCS_STORAGE'.DIRECTORY_SEPARATOR.'downloads'.DIRECTORY_SEPARATOR;

    $dir = new DirectoryIterator($storageLocation2);
    foreach ($dir as $fileinfo)
    {
      if (!$fileinfo->isDot())
      {
        $fullPathFileName1 = $storageLocation1.$fileinfo->getFilename();
        $fullPathFileName2 = $storageLocation2.$fileinfo->getFilename();

        if (!file_exists($fullPathFileName1))
        {
          copy($fullPathFileName2,$fullPathFileName1);
        }
      }
    }
  }
}

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated