Jump to content

Client File Access via API

Recommended Posts

Hi All,


I've written some PHP to extract client files from the WHMCS database because it's not a native API call.

Just opened the thread to share it with anyone who may want to use it.

I'm working on another to update the Last Login details also.

Create the SQL Connection then

Get the Files List - Pass $userID as the clientID - While loop ensures all records are put into the arrary

function getfiles($userID)


$conn = new mysqli('DBAddress', 'DBUser', 'DBPW', 'DBName')

$result = $conn->query("SELECT * FROM `tblclientsfiles` WHERE userid = $userID");
    $rows = array();
    while($row = $result->fetch_assoc()) {
        $rows[] = $row;
 return $rows;


$filesData = getfiles($userID);

 for ($counter = 0; $counter < count($rows); $counter++)
            $split = explode("_", $filesData[$counter]['filename']);
        echo "<tr><td>" . $split['1'] . "</td><td><a href='WHMCSWebsite/attachments" .$filesData[$counter]['filename']. "'>Download</a></td></tr>";

That should be enough for people to be able to extract the files list and display it through the API.

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.

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.

  • 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