本文整理汇总了PHP中uploader::addAllowedFileType方法的典型用法代码示例。如果您正苦于以下问题:PHP uploader::addAllowedFileType方法的具体用法?PHP uploader::addAllowedFileType怎么用?PHP uploader::addAllowedFileType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类uploader
的用法示例。
在下文中一共展示了uploader::addAllowedFileType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
<?php
include 'classes/upload.php';
include 'classes/smart_resize.php';
// You need to add server side validation and better error handling here
$data = array();
if (isset($_POST['submit'])) {
$max_size = 1000;
//this is the max width for your uploaded images
$filetype = $_POST['filetype'];
$description = $_POST['description'];
//upload file
$file_uploader = new uploader('files_uploaded/');
//this is the directory where your files will be stored
if ($filetype == "image") {
$file_uploader->addAllowedFileType(array('.jpeg', '.jpg', '.gif', '.png'));
} else {
$file_uploader->addAllowedFileType(array('.doc', '.docx', '.pdf', '.xls', '.xlsx', '.txt', '.rtf', '.zip'));
}
try {
$filename = $file_uploader->uploadFile('image');
if ($filename) {
list($name_file, $ext) = split('[.]', $filename);
//resize if its an image
if ($ext == 'jpeg' || $ext == 'jpg' || $ext == 'gif' || $ext == 'png') {
$image_src = "files_uploaded/" . stripslashes($filename);
$image_size = getimagesize($image_src);
if ($image_size[0] > $max_size) {
smart_resize_image($image_src, $image_src, $max_size, 0, true, 'file', false, false);
}
}