namhost Posted August 24, 2019 Share Posted August 24, 2019 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? 0 Quote Link to comment Share on other sites More sharing options...
namhost Posted August 24, 2019 Author Share Posted August 24, 2019 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. 0 Quote Link to comment Share on other sites More sharing options...
namhost Posted August 24, 2019 Author Share Posted August 24, 2019 It looks like there is only a hook for "FileDownload". I see one for "AnnouncementAdd", but not for "FileAdd", so I don't think this is going to be possible. Soooo, now instead I am adding a hook that: a) checks the folders on each page load (not ideal) b) copies the files if a copy is needed. 0 Quote Link to comment Share on other sites More sharing options...
namhost Posted August 24, 2019 Author Share Posted August 24, 2019 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); } } } } } 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.