<?php
// +------------------------------------------------------------------------+
// | class.upload.php |
// +------------------------------------------------------------------------+
// | Copyright (c) Colin Verot 2003-2010. All rights reserved. |
// | Version 0.30 |
// | Last modified 05/09/2010 |
// | Email colin@verot.net |
// | Web http://www.verot.net |
// +------------------------------------------------------------------------+
// | This program is free software; you can redistribute it and/or modify |
// | it under the terms of the GNU General Public License version 2 as |
// | published by the Free Software Foundation. |
// | |
// | This program is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
// | GNU General Public License for more details. |
// | |
// | You should have received a copy of the GNU General Public License |
// | along with this program; if not, write to the |
// | Free Software Foundation, Inc., 59 Temple Place, Suite 330, |
// | Boston, MA 02111-1307 USA |
// | |
// | Please give credit on sites that use class.upload and submit changes |
// | of the script so other people can use them as well. |
// | This script is free to use, don't abuse. |
// +------------------------------------------------------------------------+
//
/**
* Class upload
*
* @version 0.30
* @author Colin Verot <colin@verot.net>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @copyright Colin Verot
* @package cmf
* @subpackage external
*/
/**
* Class upload
*
* <b>What does it do?</b>
*
* It manages file uploads for you. In short, it manages the uploaded file,
* and allows you to do whatever you want with the file, especially if it
* is an image, and as many times as you want.
*
* It is the ideal class to quickly integrate file upload in your site.
* If the file is an image, you can convert, resize, crop it in many ways.
* You can also apply filters, add borders, text, watermarks, etc...
* That's all you need for a gallery script for instance. Supported formats
* are PNG, JPG, GIF and BMP.
*
* You can also use the class to work on local files, which is especially
* useful to use the image manipulation features. The class also supports
* Flash uploaders.
*
* The class works with PHP 4 and 5, and its error messages can
* be localized at will.
*
* <b>How does it work?</b>
*
* You instanciate the class with the $_FILES['my_field'] array
* where my_field is the field name from your upload form.
* The class will check if the original file has been uploaded
* to its temporary location (alternatively, you can instanciate
* the class with a local filename).
*
* You can then set a number of processing variables to act on the file.
* For instance, you can rename the file, and if it is an image,
* convert and resize it in many ways.
* You can also set what will the class do if the file already exists.
*
* Then you call the function {@link process} to actually perform the actions
* according to the processing parameters you set above.
* It will create new instances of the original file,
* so the original file remains the same between each process.
* The file will be manipulated, and copied to the given location.
* The processing variables will be reset once it is done.
*
* You can repeat setting up a new set of processing variables,
* and calling {@link process} again as many times as you want.
* When you have finished, you can call {@link clean} to delete
* the original uploaded file.
*
* If you don't set any processing parameters and call {@link process}
* just after instanciating the class. The uploaded file will be simply
* copied to the given location without any alteration or checks.
*
* Don't forget to add <i>enctype="multipart/form-data"</i> in your form
* tag <form> if you want your form to upload the file.
*
* <b>How to use it?</b><br>
* Create a simple HTML file, with a form such as:
* <pre>
* <form enctype="multipart/form-data" method="post" action="upload.php">
* <input type="file" size="32" name="image_field" value="">
* <input type="submit" name="Submit" value="upload">
* </form>
* </pre>
* Create a file called upload.php:
* <pre>
* $handle = new upload($_FILES['image_field']);
* if ($handle->uploaded) {
* $handle->file_new_name_body = 'image_resized';
* $handle->image_resize = true;
* $handle->image_x = 100;
* $handle->image_ratio_y = true;
* $handle->process('/home/user/files/');
* if ($handle->processed) {
* echo 'image resized';
* $handle->clean();
* } else {
* echo 'error : ' . $handle->error;
* }
* }
* </pre>
*
* <b>How to process local files?</b><br>
* Use the class as following, the rest being the same as above:
* <pre>
* $handle = new upload('/home/user/myfile.jpg');
* </pre>
*
* <b>How to set the language?</b><br>
* Instantiate the class with a second argument being the language code:
* <pre>
* $handle = new upload($_FILES['image_field'], 'fr_FR');
* $handle = new upload('/home/user/myfile.jpg', 'fr_FR');
* </pre>
*
* <b>How to output the resulting file or picture directly to the browser?</b><br>
* Simply call {@link process}() without an argument (or with null as first argument):
* <pre>
* $handle = new upload($_FILES['image_field']);
* header('Content-type: ' . $handle->file_src_mime);
* echo $handle->Process();
* die();
* </pre>
* Or if you want to force the download of the file:
* <pre>
* $handle = new upload($_FILES['image_field']);
* header('Content-type: ' . $handle->file_src_mime);
* header("Content-Disposition: attachment; filename=".rawurlencode($handle->file_src_name).";");
* echo $handle->Process();
* die();
* </pre>
*
* <b>Processing parameters</b> (reset after each process)
* <ul>
* <li><b>{@link file_new_name_body}</b> replaces the name body (default: '')<br>
* <pre>$handle->file_new_name_body = 'new name';</pre></li>
* <li><b>{@link file_name_body_add}</b> appends to the name body (default: '')<br>
* <pre>$handle->file_name_body_add = '_uploaded';</pre></li>
* <li><b>{@link file_name_body_pre}</b> prepends to the name body (default: '')<br>
* <pre>$handle->file_name_body_pre = 'thumb_';</pre></li>
* <li><b>{@link file_new_name_ext}</b> replaces the file extension (default: '')<br>
* <pre>$handle->file_new_name_ext = 'txt';</pre></li>
* <li><b>{@link file_safe_name}</b> formats the filename (spaces changed to _) (default: true)<br>
* <pre>$handle->file_safe_name = true;</pre></li>
* <li><b>{@link file_overwrite}</b> sets behaviour if file already exists (default: false)<br>
* <pre>$handle->file_overwrite = true;</pre></li>
* <li><b>{@link file_auto_rename}</b> automatically renames file if it already exists (default: true)<br>
* <pre>$handle->file_auto_rename = true;</pre></li>
* <li><b>{@link dir_auto_create}</b> automatically creates destination directory if missing (default: true)<br>
* <pre>$handle->auto_create_dir = true;</pre></li>
* <li><b>{@link dir_auto_chmod}</b> automatically attem
没有合适的资源?快使用搜索试试~ 我知道了~
高手写的一个php文件上传类,可以检查真实扩展名
共41个文件
php:30个
png:5个
html:3个
5星 · 超过95%的资源 需积分: 32 205 下载量 174 浏览量
2012-07-27
08:04:51
上传
评论 3
收藏 234KB RAR 举报
温馨提示
高手写的一个php文件上传类,可以检查真实扩展名,不过比较复杂,单是class.upload.php一个文件就有252KB,4999行,没错是只差一行不到5000行,功能可想而知,里面有测试文件index.php可以照着里面来做,版权属于原作者Colin Verot,本人纯属分享
资源推荐
资源详情
资源评论
收起资源包目录
class.upload_0.30.rar (41个子文件)
class.upload_0.30
lang
class.upload.tr_TR.php 7KB
class.upload.uk_UA.windows-1251.php 6KB
class.upload.uk_UA.php 8KB
class.upload.ca_CA.php 7KB
class.upload.de_DE.php 7KB
class.upload.ru_RU.windows-1251.php 7KB
class.upload.sk_SK.php 7KB
class.upload.id_ID.php 9KB
class.upload.hr_HR.php 7KB
class.upload.vn_VN.php 7KB
class.upload.xx_XX.php 7KB
class.upload.et_EE.php 6KB
class.upload.zh_TW.php 7KB
class.upload.ro_RO.php 7KB
class.upload.cs_CS.php 7KB
class.upload.ru_RU.php 8KB
class.upload.he_IL.php 7KB
class.upload.pl_PL.php 7KB
class.upload.zh_CN.php 6KB
class.upload.it_IT.php 7KB
class.upload.nl_NL.php 7KB
class.upload.fr_FR.php 7KB
class.upload.el_GR.php 9KB
class.upload.zh_CN.gb-2312.php 7KB
class.upload.es_ES.php 7KB
class.upload.no_NO.php 7KB
class.upload.pt_BR.php 7KB
class.upload.sv_SE.php 6KB
watermark.png 3KB
test
class.upload.php 252KB
index.html 3KB
LICENSE 18KB
upload.php 43KB
bg.gif 73B
watermark_large.png 4KB
sources
phpdoc
stylesheet.css 6KB
Variable.png 688B
Method.png 661B
class.upload.html 180KB
class.upload.php.html 1.68MB
test.png 35KB
共 41 条
- 1
xinxing1991
- 粉丝: 2
- 资源: 29
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
前往页