Make an upload space on your website

December 2016

To allow users to upload data on to your website, you need to know the original format of the data and the desired format in which it will be available for downloading. You will have to finalize the usability and limits of viewing or downloading. As a webmaster, allocating space gives you an upload webspace to save files online of various sizes and formats. The online storing feature is a powerful tool for online file sharing, or if you want to store important files that are huge in size and portable, instead of using PHP code, you can set up your own custom upload space on your website.


Intro

These days many websites offer a function allowing the user to upload files to the site. This is particularly useful for sharing files over the internet or for storing backup copies of files.

[www.yousendit.com YouSendIt.com] is a website that provides FTP uploads. However, you can get a similar service without paying using a PHP code to set up your own custom upload space on your website.

Solution

This PHP code is available on the website File Thingie. The benefit of this program is that it allows you to upload multiple files at the same time, protect them with a password, rename, move or delete the files and edit your text in HTML.

Implementation

After downloading the file and unzipping it, there are some modifications that you should make to it.
  • Rename the PHP file ft2.php as index.php
  • Insert the new username and password after this line in the code:
    # Settings - Change as appropriate. See online documentation for explanations. #, 
    • Define the new username and password as indicated below:
    • define("USERNAME", "my_username");
    • define("PASSWORD", "my_password");
  • Change the DIR declaration from define("DIR", "."); to define("DIR", "files");
  • You can also alter the storage capacity by changing define("MAXSIZE", 2000000); to define("MAXSIZE", 9999999);
  • Step 5: Finally, you can define the formats that can be uploaded where you see this code: define("FILETYPEBLACKLIST", "php phtml php3 php4 php5");
    • To add more file types you could replace it with this: define("FILETYPEBLACKLIST", "php phtml php3 php4 php5 mp3 doc xls");

What to change on your website

Once you have finished making changes, you should now create a directory to store the files on your website. Note that you should also create a subfolder that will contain the PHP file. You should, therefore, put the index.php file in this sub folder. All you have to do now is to go to http://yoursite.com/storage and insert your username and password to be able to access this space.

Important notes

Anyone can access the files you upload using File Thingie so do not use it for private material. The password is only for uploading.

It is therefore not suitable for backing up certain data, but a useful file sharing tool..
  • Note: If the automatic indexing is disabled on your web server, by going http://yoursite.com/storage/files users will not see the file list.
  • You therefore have to create a page (eg index.html) with links to each file, or add a PHP file that lists the available documents.

Related :

This document entitled « Make an upload space on your website » from CCM (ccm.net) is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.