Jfinal+DWZ使用uploadify插件实现文件上传

JFinal学习笔记(四) 实现简单的图片上传 图片上传是网站开发中非常常用的一个功能,本文将详细描述在jfinal框架下如何实现图片上传功能。 首先我在实现图片上传功能时用到了uploadify插件,因此在开发时需要引入相应的文件,分别是uploadify.css、jquery-1.10.2.js、jquery.uploadify.min.js、uploadify.swf、uploadify-cancel.png。这些文件都可以在百度中找到 阅读详情

upload.jsp


var htmlHead="<dl><dt style='width: 120px; text-align: right;'>已上传的文件:</dt><dd id='fileHtmlBody'>";
var htmlBody="";
var htmlFoot="</dd></dl>";
function onComplete(event, queueId, fileObj, response, data){
	var obj = eval( "(" + response + ")" );//转换为JSON对象
	htmlBody+="<div id='file_"+obj.id+"' style='height:25px;line-height:25px;'>";
	htmlBody+="<span style='display:none'><input type='checkbox' class='uploaded' name='fid' value='"+obj.id+"' checked/></span>";
	htmlBody+="<a class='btnAttach'></a><a title='点击右键另存为' target='_blank' href='"+obj.fileurl+"'>"
				+obj.filename+"</a> ("+obj.filesize+")<a href='javascript:deleteFile("+obj.id
				+");'><img src='styles/dwz/uploadify/cancel.png' height='13' align='middle'/></a>";
	htmlBody+="</div>";
	$("#fileList").html(htmlHead+htmlBody+htmlFoot);
}
//删除文件ajax请求
function deleteFile(id){
	$("#file_"+id).load("Main/post/deletefile/"+id);
	$("#file_"+id).remove();
	htmlBody=$("#fileHtmlBody").html();
}
//close前删除已上传的文件
function deleteUploaded(){
	$(".uploaded").each(function(){
		var fileid = $(this).val();
		deleteFile(fileid);
	});
}

------------------------------------------------------------------------

<input id="testFileInput" type="file" name="file" 
	uploader="styles/dwz/uploadify/scripts/uploadify.swf"	//必需,uploadify使用的插件
	cancelImg="styles/dwz/uploadify/cancel.png" 
	script="Main/post/uploadfile"	//必需,上传的服务端入口
	fileQueue="fileQueue" //对应下方的div,用来显示上传进度
	auto="true" 
	onComplete="onComplete"/> //单个文件上传完成执行的js函数
<div id="fileQueue" ></div>
<div class="divider"></div>
<div id="fileList" ></div> //此块用于显示已上传完成的文件


------------------------------------------------------

Post.java

public void uploadfile(){
		String saveDirectory = JFWebConfig.saveDirectory + "download";
		int maxPostSize = JFWebConfig.maxPostSize;		//1024*1024

		UploadFile file = getFile("file", saveDirectory, maxPostSize);
		String fileName = file.getFileName();
		String name=fileName.substring(0,fileName.lastIndexOf('.'));
		String filetype = fileName.substring(fileName.lastIndexOf('.') + 1);
		String filesize = FileUtils.getFileSize(file.getFile().length());
		String fileurl = "upload/" + saveDirectory + "/" + fileName;
		Tab_Downloadfile df = new Tab_Downloadfile();
		df.set("filename", name);
		df.set("fileurl", fileurl);
		df.set("filesize", filesize);
		df.set("filetype", filetype);
		if(df.save()){
			Tab_Downloadfile lastfile = Tab_Downloadfile.dao.getLastSave();
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("id", lastfile.getInt("id"));
			map.put("filename", lastfile.getStr("filename"));
			map.put("fileurl", lastfile.getStr("fileurl"));
			map.put("filesize", lastfile.getStr("filesize"));
			renderJson(map);
		}else{
			renderJson("{\"statusCode\":\"300\",\"message\":\"文件存储出错!\"}");
		}
	}

/**删除文件*/
	public void deletefile(){
		int id = getParaToInt(0);
		Tab_Downloadfile df = Tab_Downloadfile.dao.findById(id);
		if(df!=null){
			try {
				File file = new File(PathKit.getWebRootPath() + "/" + df.getStr("fileurl"));
				if (file.exists()) {
					file.delete();
				}
				df.delete();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}




jfinal配合uploadify实现图片上传 JFinal配合Uploadify实现上传 立即下载

相关推荐

dwz+php后台信息管理系统

发布一个我个人开发和使用的dwz+php后台信息管理系统,希望有人喜欢。这是一个后台信息管理系统的基础架构,功能包括用户登录,角色管理,用户管理,权限管理等。在此基础上,你可以开发你需要的各种信息管理系统。 演示地址:http://www.uadmin.cn/dwz 测试用户密码:admin 123456

DWZ的文件上传表单提交

文件上传表单提交因为Ajax不支持enctype="multipart/form-data" 所以用隐藏iframe来处理无刷新表单提交.  &lt;form method="post" action="url" class="pageForm required-validate" enctype="multipart/form-data" onsubmit="return iframeCa

大Z小z的博客 1242

基于deepseek本地模型的本地知识库构建

通过以上步骤,你已经成功构建了一个基于 AnythingLLM 和 LM Studio 的本地知识库。这个系统不仅能够高效地存储和检索知识,还能结合强大的语言模型生成准确的回答。你可以根据自己的需求进一步扩展和优化这个系统,比如增加更多的文档格式支持、优化检索算法等。

qq_30178745的博客 1383

jfinal + uploadify 插件小问题

jfinal + upload 插件传递参数的问题 jfinal getpara() 获取中文乱码 .getBytes("ISO-8859-1"),"utf-8")

yudi12345的博客 384

深入MoveIt与OMPL集成开发:从源码编译到自定义规划算法实战

本文详细介绍了如何从源码编译集成MoveIt与OMPL,并实现自定义规划算法的完整流程。通过清理环境、获取源码、解决编译依赖与错误,最终指导开发者创建并集成名为MyRRT的自定义规划算法,从而实现对机器人运动规划栈的深度定制与优化。

h0i1j2k3l的博客 468

TI DSP从COFF切换到EABI输出格式的5个关键修改点(TMS320F280025实测)

本文基于TMS320F280025实测,详细解析了TI DSP从COFF切换到EABI输出格式的5个关键修改点。核心差异在于EABI遵循ELF标准,涉及链接器优化、RAM数据共享、工具链升级、double数据类型位宽变化及链接器命令文件重构。迁移时需使用.retain指令防止关键数据被优化,利用NOINIT段保护共享RAM,并更新hex2000等工具,以确保BootLoader与应用程序稳定运行。

weixin_29189381的博客 266

dwz 上传文件问题

问题    the request doesn't contain a multipart/form-data or multipart/mixed stream, 上传页面                           环境是springMVC DWZ  上传方式是common-upload 昨天开发一半,早上来上班,发现一传东西就报错 he re

2055

YOLOV8主干改进方法:C2f-Dual——DualConv轻量化双卷积设计(附改进代码)

DualConv是一种创新的卷积网络结构,旨在构建轻量级的深度神经网络。它通过结合3×3和1×1的卷积核处理相同的输入特征映射通道,优化了信息处理和特征提取。DualConv利用组卷积技术高效排列卷积滤波器,大大降低了计算成本和参数数量。

m0_74890428的博客 4700

JFinal+WebUploader实现图片的异步上传

关于WebUploaderWebUploader是由Baidu WebFE(FEX)团队开发的一个简单的以HTML5为主,FLASH为辅的现代文件上传组件。 界面友好,使用方便,稍作修改,可快速上手。 官网:这里写链接内容如何使用webuploader到官网去下载完整的源代码包,如图解压之后只需要这三个文件夹下的文件资源,如图 在项目根目录路径下新建文件夹webuploader-0.1.5,然

白夜的随笔 6632

论文分享|ECCV2022,PATnet,Cross-Domain Few-Shot Semantic Segmentation,CDFSS新基准,文末有复现教程

这篇论文提出的跨域小样本语义分割(CD-FSS)任务,旨在将源域学习的分割能力迁移到目标域,仅需少量标注样本。针对传统小样本分割方法在跨域场景性能下降的问题,作者提出了基于金字塔锚点变换的网络(PATNet),通过将域相关特征转换为域无关特征,并引入任务自适应微调推理(TFI)提升目标域适应能力。实验表明,PATNet在1-shot和5-shot设置下分别比现有方法提升8.49%和10.61%的准确率。同时,作者构建了CD-FSS基准并设计了任务难度评估指标。代码和数据集已开源,复现难度中等。

m0_74277350的博客 1095

yolov8 转华为昇腾om脚本

yolov8 转华为昇腾om脚本

jacke121的专栏 1601

dwz xheditor编辑器文件上传

转载地址:http://blog.youkuaiyun.com/sean_cd/article/details/8027315 client------------------------ <textarea name="fld_content" rows="23" cols="83"

Terry - 专注外贸B2C 1244

AUTOSAR从入门到精通-复杂设备驱动(CDD)

CDD是复杂设备驱动的首字母缩写主要为驱动程序或复杂驱动程序,但不限于驱动程序。复杂驱动程序是一种未被AUTOSAR标准化的软件实体,可以通过AUTOSAR接口和/或基本软件模块api访问。 CDD是位于基础软件复杂驱动层的特定模块,与标准BSW模块或Rte交互。 CDD可能需要与分层软件体系结构的模块连接 分层软件架构的模块可能需要连接到CDD CDD可能需要通过Rte连接swc。

getusushu的博客 4194

Jfinal下使用WebUploader进行分片上传

背景 大文件直传易受网络波动而失败,同时运维人员一直维护失败的队列不合理,需要实现分片上传,webuploader已经是很成熟的分片上传插件了,这里使用webuploader进行分片。 前端 分片通过常规配置可得,主要交互通过以下两个事件可得: beforeSend:分片发送前校验文件,分片若已存在则跳过(这里保证了失败重新传能快速跳过已上传部分) uploadSuccess:文件整体上...

Wilson的博客 1119

【ArcGIS Engine二次开发】入门基础(2):ArcGIS开发方式(VBA、DLL、Add-in、Engine)对比

文章目录2.1 使用VBA进行桌面软件开发2.1.1 VBA开发方式2.1.1 VBA代码的安全性2.2 使用DLL进行桌面软件开发2.2.1 DLL开发方式2.2.2 DLL功能的应用部署2.3 使用Add-in进行桌面软件开发2.4 使用ArcGIS Engine构建独立应用程序 对于桌面GIS应用来说,ArcGIS平台不仅提供了用于开发独立运行的GIS应用软件的二次开发工包ArcGIS Engine,还提供了对ArcGIS Deskop桌面软件进行扩展的开发的话,在开发个具体的GIS 行业应用软件时

智慧空间实验室 6510

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

JFinal3.4 Controller之文件操作(上传以及下载)

最近做项目用到了文件上传以及下载的一些接口操作,恰好JFinal3.4 自带这些功能吗,下面说一下关于文件上传下载的一些小技巧。 一、getFile文件上传 JFinal让文件上传变得更加简单,几行代码调用就能完成文件上传功能。在文件上传前端代码的表单中一定要加上enctype="multipart/form-data",否则不能正常完成上传任务。这个属性其实是改变了表单的MIME编码,让表单支持二进制数据的传输。 1、编写html页面 <!DOCTYPE html> <ht

熬过万丈孤独,藏下星辰大海 1587

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

DWZ框架 实现上传功能

qianta                         onsubmit="return validateCallback(this,dialogAjaxDone);">                                                         导入Excel:                

执子之手 与子偕老--小魏专栏 3703

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

jquery ajax实现上传文件代码,带进度条

原文:jquery ajax实现上传文件代码,带进度条源代码下载地址:http://www.zuidaima.com/share/1550463291116544.htm ajax上传文件代码,带进度条的。 首页 http://localhost:端口/项目名/common/test.htm 上传中 标签:jqueryajax上传进度条话题:W...

810364804 375

DWZ+jFinal结合写出的分页!

新学习了jFinal,但

u013682582的专栏 1502

Struts2+ibatis+dwz 框架实现uploadify上传文件

下载js包 (3.2版本) 下载地址:http://www.uploadify.com/download/ 解压后文件: jsp页面 .fileQueue li{margin:5px auto;padding:2px 15px 2px;width:85%;height:30px;line-height:30px;font-size:14px;border:1px dashed

canyingtian的博客 880

ThinkPHP+DWZ(xhEditor)上传图片

DWZ使用xhEditor作为编辑器。 一、HTML页Form无需添加 enctype="multipart/form-data" 也无需添加别的脚本 二、PHP页 //上传 public function upload() { $upload = new \Think\Upload();// 实例化上传类 $upload->maxSize = 314572

leejianjun的博客 1847
上一篇: mysql外键删不掉的问题
下一篇: Jfinal下连接SQLServer
ThisTimed
博客等级 码龄14年 1粉丝 3原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值