Common Notices
• Please, use a $fileUploader->Debug(true); before you say "Why Nothing Works ?!"
• 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");
## *** 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);
Define whether to show file icons or not.
## *** show file icons $fileUploader->ShowIcons(true);
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
---------------------------------------------------------------------------
Set the maximum number of files that the user is allowed to upload simultaneously:
## *** set the maximum number of files $fileUploader->SetNumberOfFiles(6);
Set maximum allowed size for uploaded files
## *** set maximum size $fileUploader->SetMaxSize("200mb");
Set allowed extensions for uploaded files
## *** set allowed extensions $fileUploader->AddAllowedExtension(array("txt","gif","zip"));
Step 4. 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 5. Display File Uploader
---------------------------------------------------------------------------
Now you can display FileUploader on the screen.
## *** display file uploader $fileUploader->Display();