Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 265635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:47:14+00:00 2026-05-11T22:47:14+00:00

We need to create a file management interface that integrates with the clients current

  • 0

We need to create a file management interface that integrates with the clients current website built on cakephp.

The file manager must only let the users see the files that they have permissions too.

The user will be able to upload files(of any size) and have other users download those files (if permissions allow).

This is no problem for many file management systems that we can purchase but none that I can find will integrate with their current log in system. The client only wants the users to log in once to access their user CP and their files. So as far as I can see our only option is to build a file management interface ourselves.

What are some of the options that we have to allow uploads using PHP? I understand that we need to increase the php upload limit, but is there a ceiling that php/apache will allow?

The files will likely cap out at approximately 150MB if that is relevant, however there may be situations where the file sizes will be larger.

Also what are the do’s and don’ts of file upload/control on a Linux server?

I suppose I have no real ‘specific’ questions but would like some advise on where to start and some of the typical pitfalls we will run into.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T22:47:14+00:00Added an answer on May 11, 2026 at 10:47 pm

    File management is quite easy, actually. Here are some suggestions that may point you in the right direction.

    First of all, if this is a load balanced web server situation, you’ll need to step up the complexity a little in order to put the files in one common place. If that’s the case, ping me and I’ll be happy to send you our super-light file server/client we use for that same situation.

    There are a few variables you will want to affect in order to allow larger uploads. I recommend using apache directives to limit these changes to a particular file:

    <Directory /home/deploy/project/uploader>
        php_value max_upload_size "200M"
        php_value post_max_size "200M"
        php_value max_input_time "1800"
    
        # this one depends on how much processing you are doing to the file
        php_value memory_limit "32M" 
    </Directory>
    

    Architecture:

    Create a database table that stores some information about each file.

    CREATE TABLE `File` (
      `File_MNID` int(10) unsigned NOT NULL AUTO_INCREMENT,
      `Owner_Field` enum('User.User_ID', 'Resource.Resource_ID') NOT NULL,
      `Owner_Key` int(10) unsigned NOT NULL,
      `ContentType` varchar(64) NOT NULL,
      `Size` int(10) NOT NULL,
      `Hash` varchar(40) NOT NULL,
      `Name` varchar(128) NOT NULL,
      PRIMARY KEY (`File_MNID`),
      KEY `Owner` (`Owner_Field`,`Owner_Key`)
    ) ENGINE=InnoDB 
    

    What is Owner_Field and Owner_Key? A simple way to say what “entity” owns the file. In this specific case there were multiple types of files being uploaded. In your case, a simple User_ID field may be adequate.

    The purpose of storing the owner is so that you can restrict who can download and delete the file. That will be crucial for protecting the downloads.

    Here is a sample class that can be used to accept the file uploads from the browser. You’ll need to modify it to suit, of course.

    There are a few things to note about the following code. Since this is used with an Application Server and a File Server, there are a few things to “replace”.

    1. Any occurrences of App::CallAPI(...) will need to be replaced with a query or set of queries that do the “same thing”.
    2. Any occurrences of App::$FS->... will need to be replaced with the correct file handling functions in PHP such as move_uploaded_file, readfile, etc…

    Here it is. Keep in mind that there are functions here which allow you to see files owned by a given user, delete files, and so on and so forth. More explanation at the bottom…

    <?php
    
    class FileClient
    {
        public static $DENY     = '/\.ade$|\.adp$|\.asp$|\.bas$|\.bat$|\.chm$|\.cmd$|\.com$|\.cpl$|\.crt$|\.exe$|\.hlp$|\.hta$|\.inf$|\.ins$|\.isp$|\.its$| \.js$|\.jse$|\.lnk$|\.mda$|\.mdb$|\.mde$|\.mdt,\. mdw$|\.mdz$|\.msc$|\.msi$|\.msp$|\.mst$|\.pcd$|\.pif$|\.reg$|\.scr$|\.sct$|\.shs$|\.tmp$|\.url$|\.vb$|\.vbe$|\.vbs$|vsmacros$|\.vss$|\.vst$|\.vsw$|\.ws$|\.wsc$|\.wsf$|\.wsh$/i';
    
        public static $MAX_SIZE = 5000000;
    
        public static function SelectList($Owner_Field, $Owner_Key)
        {
            $tmp = App::CallAPI
            (
                'File.List',
                array
                (
                    'Owner_Field' => $Owner_Field,
                    'Owner_Key' => $Owner_Key,
                )
            );
    
            return $tmp['Result'];
        }
    
        public static function HandleUpload($Owner_Field, $Owner_Key, $FieldName)
        {
            $aError = array();
    
            if(! isset($_FILES[$FieldName]))
                return false;
            elseif(! is_array($_FILES[$FieldName]))
                return false;
            elseif(! $_FILES[$FieldName]['tmp_name'])
                return false;
            elseif($_FILES[$FieldName]['error'])
                return array('An unknown upload error has occured.');
    
            $sPath = $_FILES[$FieldName]['tmp_name'];
            $sHash = sha1_file($sPath);
            $sType = $_FILES[$FieldName]['type'];
            $nSize = (int) $_FILES[$FieldName]['size'];
            $sName = $_FILES[$FieldName]['name'];
    
            if(preg_match(self::$DENY, $sName))
            {
                $aError[] = "File type not allowed for security reasons.  If this file must be attached, please add it to a .zip file first...";
            }
    
            if($nSize > self::$MAX_SIZE)
            {
                $aError[] = 'File too large at $nSize bytes.';
            }
    
            // Any errors? Bail out.
            if($aError)
            {
                return $aError;
            }
    
    
            $File = App::CallAPI
            (
                'File.Insert',
                array
                (
                    'Owner_Field'        => $Owner_Field,
                    'Owner_Key'            => $Owner_Key,
                    'ContentType'        => $sType,
                    'Size'                => $nSize,
                    'Hash'                => $sHash,
                    'Name'                => $sName,
                )
            );
    
            App::InitFS();
            App::$FS->PutFile("File_" . $File['File_MNID'], $sPath);
    
            return $File['File_MNID'];
    
        }
    
        public static function Serve($Owner_Field, $Owner_Key, $File_MNID)
        {
            //Also returns the name, content-type, and ledger_MNID
            $File    = App::CallAPI
            (
                'File.Select',
                array
                (
                    'Owner_Field'     => $Owner_Field,
                    'Owner_Key'     => $Owner_Key,
                    'File_MNID'     => $File_MNID
                )
            );
    
            $Name     = 'File_' . $File['File_MNID'] ;
    
            //Content Header for that given file
            header('Content-disposition: attachment; filename="' . $File['Name'] . '"');
            header("Content-type:'" . $File['ContentType'] . "'");
    
            App::InitFS();
            #TODO
            echo App::$FS->GetString($Name);
    
        }
    
        public static function Delete($Owner_Field, $Owner_Key, $File_MNID)
        {
    
            $tmp = App::CallAPI
            (
                'File.Delete',
                array
                (
                    'Owner_Field' => $Owner_Field,
                    'Owner_Key' => $Owner_Key,
                    'File_MNID' => $File_MNID,
                )
            );
    
            App::InitFS();
            App::$FS->DelFile("File_" . $File_MNID);
        }
    
        public static function DeleteAll($Owner_Field, $Owner_Key)
        {
            foreach(self::SelectList($Owner_Field, $Owner_Key) as $aRow)
            {
                self::Delete($Owner_Field, $Owner_Key, $aRow['File_MNID']);
            }
        }
    
    }
    

    Notes:

    Please keep in mind that this class DOES NOT implement security. It assumes that the caller has an authenticated Owner_Field and Owner_Key before calling FileClient::Serve(...) etc…

    It’s a bit late, so if some of this doesn’t make sense, just leave a comment. Have a great evening, and I hope this helps some.

    PS. The user interface can be simple tables and file upload fields, etc.. Or you could be fancy and use a flash uploader…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 228k
  • Answers 228k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This is almost certainly due to somebody cut-and-pasting from an… May 13, 2026 at 1:34 am
  • Editorial Team
    Editorial Team added an answer If you are willing to try a commercial product, my… May 13, 2026 at 1:34 am
  • Editorial Team
    Editorial Team added an answer I just added an answer to a similar question here;… May 13, 2026 at 1:34 am

Related Questions

I am working on a Web based organisation tool. I am not aiming the
Currently all our files are stored on a Windows network drive and with 15
I need to add more views to a view for handling multiple webaddress and
I'm not overly familiar with Tomcat, but my team has inherited a complex project

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.