Recommend this page to a friend! |
Classes of Rizza | PHP Uploader class | docs/index.md | Download |
|
DownloadUploader-classThe uploader-class attempts to greatly reduce the amount of code required to make uploading files possible in php. Dependencies include: - jQuerey - Access to session functionality. (including the use of cookies) The code required to produce an upload form is as follows:
When the file is uploaded to the server, using ajax, an endpoint has to be available so the file can be validated. It is recommended this php file is not hidden behind any .htaccess rules. The example code for this file is as follows:
The uploader-classA class to allow for upload of files to specified locations on the given server. Should handle all client and sever side interaction during upload of files via AJAX.This includes: 1. Generation of HTML for client. 2. The handling of JavaScript to send the file to the server. 3. To store session variables so uploads can be accepted and/or validated before being placed at the given directory.
Properties
__construct ( \$dir\_to\_upload\_to, \$accepted\_datatypes, \$file\_name, \$upload\_endpoint, \$max\_size = 52428800 )string$dir_to_upload_to* gives a specified upload directory string[]$accepted_datatypesA list of the accepted datatypes (must be in mime format without "" wildcards) string$file_name* The file name that should be held as the name of the file upon it being uploaded string$upload_endpoint* The endpoint the upload handle should try to upload information to. number$max_size* maximum accepted size of file uploaded(in bytes) Things of note:1. File uploaded automatically overwrite other files. This is true of all defined mime types. 2. Mime-types need to be used carefully , the "*" wildcard cannot be used in any capacity. Only direct mime types can be given. 3. The php_fileinfo extention needs to be enabled. |