Getting Started with ApPHP AJAX File Uploader (v2.0.0 or above)


Common Notices


• Do not put ApPHP AJAX File Uploader code into another HTML Form: <form>...</form>
• Always put your code inside <html>...</html> tags



Getting Started

Step 1. Creating File Uploader object


Make sure you define a valid relative (virtual) path to the fileuploader.class.php file.
## *** include FileUploader class
define('UPLOADER_DIR', '');
require_once(UPLOADER_DIR.'fileuploader.class.php');      
ApPHP File Uploader uses several JS- and CSS-files which are included in the page body as soon as the Display function is called. If you want the inclusions to happen in the specific section of the page, you can call static IncludeJsAndCssFiles function.
## *** include CSS and JS files
FileUploader::IncludeJsAndCssFiles();
Now the File Uploader object can be created.
## *** create FileUploader object
$fileUploader = new FileUploader();



Step 2. General Settings


If you want to use several independently configured FileUploader objects on a single page, you should set unique numeric (integer-valued) identifier for this FileUploader object.
## *** set id
$fileUploader->SetId(42);
ApPHP AJAX File Uploader supports embedded CSS styles: "dark", "light" and "simple". You can choose style using function "SetStyle". Select appropriate style to suit your needs.
## *** set CSS style
$fileUploader->SetStyle("dark");
Define whether the debug mode is turned on or not.
## *** show debug info - false|true
$fileUploader->Debug(false);
Set folder where uploaded files are moved to
## *** set folder
$fileUploader->SetFolder("Black Hole");
Define whether progress tracking is enabled. To use this feature you must install PECL UploadProgress extension first (for instructions refer to "Installation.htm" file)
## *** show progress - false|true
## *** (PECL UploadProgress extension must be installed first)
$fileUploader->ShowProgress(true);



Step 3. Filter rules


Specify whether file uploading starts immediately after it was added
## *** possible values - false|true
$fileUploader->LoadFilesOnSelect(false);
Specify whether the destination folder should be created automatically if it doesn't exist
## *** possible values - false|true
$fileUploader->CreateFolderIfNeeded(false);
Allow to delete files after uploading
## *** possible values - false|true
$fileUploader->AllowDeleteFiles(false);
Display file size after uploading
## *** possible values - false|true
$fileUploader->ShowFileSizeAfterUpload(true);
Overwrite existing files
## *** possible values - false|true
$fileUploader->OverwriteFiles(true);
Add a hidden field to the form being submitted
## Example: $fileUploader->AddHiddenField('key','value');
$fileUploader->AddHiddenField('director','Gilliam');



Step 4. Naming rules.


Define whether to show file icons or not.
## *** show file icons
$fileUploader->ShowIcons(true);
Specifies whether to show clickable images for 'upload' and 'remove' commands
## *** show clickable images (true) or buttons (false)
$fileUploader->UseYesNoPictures(true);
Specifies whether to show 'Upload all' button
## *** show 'Upload all' button
$fileUploader->ShowUploadAllButton(true);
Specifies whether to show 'Clear all' button
## *** show 'Clear all' button
$fileUploader->ShowClearAllButton(true);
Specifies number of columns displayed in file viewer
## *** number of columns displayed in file viewer - integer
$fileUploader->SetNumColumnsForViewer(2);



Step 5. Display File Uploader


Set allowed extensions for uploaded files
## *** set allowed extensions
$fileUploader->AddAllowedExtension(array('txt','gif','zip'));
Set maximum allowed size for uploaded files
## *** set maximum size
$fileUploader->SetMaxSize("200mb");
Set the maximum number of files that the user is allowed to upload simultaneously:
## *** set the maximum number of files
$fileUploader->SetNumberOfFiles(6);



Step 6. Naming rules.


Now you may define what names will be given to uploaded files. If you don't want their names to change, don't do anything. But you should know that ApPHP AJAX File Uploader is able to generate random names for uploaded files
## *** uploaded files are given random generated names - true|false
$fileUploader->UseRandomNames(false);
It can also add a prefix or a postfix to each uploaded file's name
## *** set prefix/postix which will be added to uploaded files' names
$fileUploader->UsePrefix("prefix_");
$fileUploader->UsePostfix("_postfix");
If you don't want existing files with identical names to be overwritten, turn on UseSuffixes option. Then the new files will be given names such as filename{1}.txt, filename{2}.txt etc.
## *** add suffixes like {1},{2} when file names are identical
$fileUploader->UseSuffixes(true);



Step 7. Display File Uploader


Now you can display FileUploader on the screen.
## *** display file uploader
$fileUploader->Display();
You can also display file viewer in order to see what files are there in the folder specified for uploading.
## *** display file viewer
$fileUploader->DisplayViewer();
Create Your Free Account
Please remember that this information is essential to use our services correctly.
After creating the account you will be able to download all of our FREE products.
Fields marked with * are mandatory






Please send me information about updates, new products, specials and discounts from ApPHP!
We recommend that your password should be at least 6 characters long and should be different from your username/email. Please use only letters of the English alphabet to enter your name.

Your e-mail address must be valid. We use e-mail for communication purposes (order notifications, etc). Therefore, it is essential to provide a valid e-mail address to be able to use our services correctly.

All your private data is confidential. We will never sell, exchange or market it in any way. Please refer to Privacy Policy.

By clicking "Create Account", you are indicating that you have read and agree to the ApPHP Terms & Conditions.