模板文件:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link href="/Public/jquery.uploadify-v2.1.0/example/css/default.css" rel="stylesheet" type="text/css" />
<link href="/Public/jquery.uploadify-v2.1.0/uploadify.css" rel="stylesheet" type="text/css" />
<script charset="utf-8" type="text/javascript" src="/Public/jquery.uploadify-v2.1.0/jquery-1.3.2.min.js"></script>
<script charset="utf-8" type="text/javascript" src="/Public/jquery.uploadify-v2.1.0/swfobject.js"></script>
<script charset="utf-8" type="text/javascript" src="/Public/jquery.uploadify-v2.1.0/jquery.uploadify.v2.1.0.min.js"></script> <style type="text/css">
#image{
height:300px;
width:720px;
border:1px #969594 solid;
}
</style> <title>图片上传</title>
</head>
<body> <form id="form1" enctype="multipart/form-data" > <div id="fileQueue" style='height:200px;display:none'></div>
<input type="file" name="uploadify" id="uploadify" multiple="true" />
</div> </form>
<div id="image" ></div> <script type="text/javascript">
$(document).ready(function () {
$("#uploadify").uploadify({
'uploader':'/Public/jquery.uploadify-v2.1.0/uploadify.swf', //swf路径
'script': '/Code/file', //后台处理文件上传的路径
'cancelImg':'/Public/jquery.uploadify-v2.1.0/cancel.png', //按钮背景图片的路径
'folder': '/Uploads',
'method':'post',
'buttonText':'file',
'fileExt': '*.jpg;*.gif,*.png', //允许上传的文件格式为*.jpg,*.gif,*.png
'fileDesc': 'Web Image Files(.JPG,.GIF,.PNG)', //过滤掉除了*.jpg,*.gif,*.png的文件
'queueID': 'fileQueue',
'sizeLimit': '2048000', //最大允许的文件大小为2M
'fileDataName':'uploadify',
'auto': false,
'queueSizeLimit':15,
'simUploadLimit':15,
'removeCompleted':false,
'multi':true,
'onCancel': funCancel, //当用户取消上传时
'onComplete': funComplete, //完成上传任务
'OnError': funError //上传发生错误时
});
});
//用户取消函数
function funCancel(event, ID, fileObj, data) {
alert('您取消了操作');
return;
}
//图片上传发生的事件
function funComplete(event, ID, fileObj, response, data) { //alert('上传事件');
if (response == 0) {
alert('图片' + fileObj.name + '操作失败');
return false;
}else{
var str=$('#image').html();
var add="<img src='"+"/Uploads/"+response+"'" +"style='margin-left:15px;margin-top:15px'/></img>";
str+=add;
$('#image').html(str);
return true;
}
} //上传发生错误时。
function funError(event, ID, fileObj, errorObj) {
//alert('错误事件');
alert(errorObj.info);
return;
}
</script>
<a href="javascript:$('#uploadify').uploadifyUpload()">上传</a>|
</body>
</html> 控制器类: <?php
/*
* 新闻类
*/
class ArticleAction extends Action{ //
/*public function load()
{
import('@.ORG.editor');
$ob=new editor("800px",'400px','editor');
$str=$ob->userJs();
$editor=$ob->createEditor();
$this->assign("str",$str);
$this->assign("editor",$editor);
$this->display();
}
//
public function php()
{
import('@.ORG.editor');
$ob=new editor( );
$content=$ob->getEditorContent();
$this->assign('content',$content);
$this->display();
} */ public function file()
{ //加载文件上传,图片处理类
import("@.ORG.UploadFile");
//导入上传类
$upload = new UploadFile();
//设置上传文件大小
$upload->maxSize=3292200;
//设置上传文件类型
$upload->allowExts=explode(',','jpg,gif,png,jpeg');
//设置附件上传目录
$upload->savePath='./Uploads/';
//设置需要生成缩略图,仅对图像文件有效
$upload->thumb = true;
// 设置引用图片类库包路径
$upload->imageClassPath ='@.ORG.Image';
//设置需要生成缩略图的文件后缀
$upload->thumbPrefix='m_,s_'; //生产2张缩略图
//设置缩略图最大宽度
$upload->thumbMaxWidth='400,100';
//设置缩略图最大高度
$upload->thumbMaxHeight='400,100';
//设置上传文件规则
$upload->saveRule='uniqid';
//删除原图
$upload->thumbRemoveOrigin=true;
if( !$upload->upload() )
{
echo '0';
}else{
$info=$upload->getUploadFileInfo();
$src='s_'.$info[0]['savename'];
echo $src;
} }
public function preview ()
{
$this->display();
}
}

  

php thinkphp uploadify的更多相关文章

  1. ThinkPHP+uploadify+upload+PHPExcel 无刷新导入数据

    前端HTML+JQuery  备注Jquery需要1.x版本,不能用2.x版本 1.引入必要文件及上传input <load file="__PUBLIC__/js/jquery-1. ...

  2. ThinkPHP Uploadify 图片上载

    从官方网站下载的Uploadify最新版本:http://www.uploadify.com/download/ jQuery库是1.7.1版本. 下载好的Uploadify目录下面的文件有: 用到的 ...

  3. 使用ThinkPHP+Uploadify实现图片上传功能

    首先,将下载的Uploadify压缩包解压放到公共文件夹内.实现代码如下: 前台html部分: <script src="/uploadify/jquery.min.js" ...

  4. 在Nginx上部署ThinkPHP,解决Pathinfo问题

    在Nginx上部署ThinkPHP,解决Pathinfo问题 事实上.要解决nginx不支持pathinfo的问题.有两个解决思路,一是不使用pathinfo模式,二是改动nginx的配置文件,使它支 ...

  5. ThinkPHP模版引擎之变量输出具体解释

    ThinkPHP模版引擎之变量输出具体解释 使用ThinkPHP开发有一定时间了,今日对ThinkPHP的模板引擎变量解析深入了解了一下.做出一些总结,分享给大家供大家參考. 详细分析例如以下: 我们 ...

  6. php中上传图片,原生代码

    一.实现图片上传方法一 html的写法: <form action="handle.php" name="form" method="post& ...

  7. ThinkPHP 3.2.3集成uploadify上传控件

    uploadify控件有一个坑爹的问题,就是文件上传时会session丢失,官方解释http://www.uploadify.com/documentation/uploadify/using-ses ...

  8. 关于ThinkPHP下使用Uploadify插件 仅有火狐提示HTTP Error (302)错误的解决办法

    'VAR_SESSION_ID' => 'session_id', //修复uploadify插件无法传递session_id的bug 首先在项目目录中的Common/Conf/config.p ...

  9. 基于thinkphp的uploadify上传图功能

    php Action server端 <?php /*  * To change this template, choose Tools | Templates  * and open the ...

随机推荐

  1. code -结合实例总结代码下拉流程

    1.查看手机需要的版本 1)如果手机本来就可以正常工作,可以使用指令 zhangshuli@zhangshuli-MS-:~/Desktop/day_note/plan$ adb shell getr ...

  2. FZU 2205 据说题目很水

    2205 据说题目很水 Accept: 199    Submit: 458Time Limit: 1000 mSec    Memory Limit : 32768 KB Problem Descr ...

  3. restcontroller和controller区别

    http://www.cnblogs.com/softidea/p/5884772.html#undefined http://blog.csdn.net/blueheart20/article/de ...

  4. [Angular] Custom directive Form validator

    Create a directive to check no special characters allowed: import {Directive, forwardRef} from '@ang ...

  5. [Vue + TS] Use Properties in Vue Components Using @Prop Decorator with TypeScript

    With properties we can follow a one-way parent→child flow communication between components. This les ...

  6. 24.C语言最全排序方法小结(不断更新)

    希尔排序: 该方法的基本思想是:先将整个待排元素序列切割成若干个子序列(由相隔某个“增量”的元素组成的)分别进行直接插入排序,然后依次缩减增量再进行排序,待整个序列中的元素基本有序(增量足够小)时,再 ...

  7. Spark应用程序部署工具Spark Submit

    不多说,直接上干货!  spark-submit在哪个位置 [spark@master ~]$ cd $SPARK_HOME/bin [spark@master bin]$ pwd /usr/loca ...

  8. pt模型

    top-down

  9. Jpa 的Persistence.xml配置讲解

    <?xml version="1.0"?> <persistence xmlns="http://java.sun.com/xml/ns/persist ...

  10. ASP.NET MVC 入门4、Controller与Action

    原帖地址:http://www.cnblogs.com/QLeelulu/archive/2008/10/04/1303672.html Controller是MVC中比較重要的一部分.差点儿全部的业 ...