1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
<?php
/**
* TfMimetypes trait file.
*
* Provides a list of common (permitted) mimetypes for file uploads.
*
* @copyright Simon Wilkinson 2013+ (https://tuskfish.biz)
* @license https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html GNU General Public License (GPL) V2
* @author Simon Wilkinson <[email protected]>
* @since 1.1
* @package core
*/
// Enable strict type declaration.
declare(strict_types=1);
if (!defined("TFISH_ROOT_PATH")) die("TFISH_ERROR_ROOT_PATH_NOT_DEFINED");
/**
* Provides a list of common (permitted) mimetypes for file uploads.
*
* @copyright Simon Wilkinson 2013+ (https://tuskfish.biz)
* @license https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html GNU General Public License (GPL) V2
* @author Simon Wilkinson <[email protected]>
* @version Release: 1.0
* @since 1.1
* @package core
*
*/
trait TfMimetypes
{
/**
* Returns an array of mimetypes that are permitted for upload to the media directory.
*
* NOTE: Adding HTML or any other scripting language or executable to this list would be a
* BAD IDEA, as such files can include PHP code, although uploaded files have execution
* permissions removed and are stored outside of the web root in order to prevent direct access
* by browser.
*
* @return array Array of permitted mimetypes as file extensions.
*
*/
public function getListOfPermittedUploadMimetypes()
{
return array(
"doc" => "application/msword", // Documents.
"docx" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"pdf" => "application/pdf",
"ppt" => "application/vnd.ms-powerpoint",
"pptx" => "application/vnd.openxmlformats-officedocument.presentationml.presentation",
"odt" => "application/vnd.oasis.opendocument.text",
"ods" => "application/vnd.oasis.opendocument.spreadsheet",
"odp" => "application/vnd.oasis.opendocument.presentation",
"xls" => "application/vnd.ms-excel",
"xlsx" => "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"gif" => "image/gif", // Images.
"jpg" => "image/jpeg",
"png" => "image/png",
"mp3" => "audio/mpeg", // Audio.
"oga" => "audio/ogg",
"ogg" => "audio/ogg",
"wav" => "audio/x-wav",
"mp4" => "video/mp4", // Video.
"ogv" => "video/ogg",
"webm" => "video/webm",
"zip" => "application/zip", // Archives.
"gz" => "application/x-gzip",
"tar" => "application/x-tar"
);
}
}