本文整理汇总了PHP中uploader::uploadFile方法的典型用法代码示例。如果您正苦于以下问题:PHP uploader::uploadFile方法的具体用法?PHP uploader::uploadFile怎么用?PHP uploader::uploadFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类uploader
的用法示例。
在下文中一共展示了uploader::uploadFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
$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);
}
}
$http_server = "http://scaredrabbit.net/jot/";
//full URL - http://yourwebsite.com/
$file_path = $http_server . "files_uploaded/" . $filename;
$data = array('new_file' => $file_path, 'file_description' => $description, 'file_type' => $filetype, 'error_msg' => '');
} else {