博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[转载]用JSP/Servlets实现Web方式的文件上传
阅读量:2447 次
发布时间:2019-05-10

本文共 1275 字,大约阅读时间需要 4 分钟。

用JSP/Servlets实现Web方式的文件上传
Use JSP and Servlet to Upload file to server is becoming a
common task now.
Below is a simple example use the jspsmart free component which
implements it.
You can download the free package from JSPSMART
1. Html File
action="uploadImage.jsp" ENCTYPE="multipart/form-data"
target=_self>
广告图片上载
广告图片: name="adsImage" size="20">
   
<!--
close this window
--&gt
2. JSP File
java.sql.*,java.util.* "%>
class="com.jspsmart.upload.SmartUpload" />
//Initialization
mySmartUpload.init(config);
mySmartUpload.service(request,response);
//Set Restriction
mySmartUpload.setAllowedFilesList("gif,bmp,jpeg,jpg");
mySmartUpload.setTotalMaxFileSize(51200);
// Upload
try{
mySmartUpload.upload();
}
catch(Exception e){
out.println("
Upload File Fail!
"JavaScript:window.history.back();">back
");
out.println("Notes:");
out.println("
  • You must set correct File
    Name.
");
out.println("
  • You file size must be less than
    50K.
");
out.println("
  • You can only upload .Gif .jpeg .jpg and
    .bmp files.
");
return;
}
//save file to disk
mySmartUpload.getFiles().getFile(0).saveAs("/" +
"FileName");
 
%>
3. Servlet File (you can do it yourself)

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/374079/viewspace-131129/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/374079/viewspace-131129/

你可能感兴趣的文章
如何在SQL Server Management Studio中创建和配置链接服务器以连接到MySQL
查看>>
使用PowerShell和T-SQL在多服务器环境中规划SQL Server备份和还原策略
查看>>
ansi_nulls_影响查询结果SQL Server SET选项-SET ANSI_NULLS,SET ANSI_PADDING,SET ANSI_WARNINGS和SET ARITHABORT
查看>>
使用Microsoft数据迁移助手在Oracle数据库和SQL Server之间迁移的具体示例
查看>>
大数据数据科学家常用面试题_面试有关数据科学,数据理解和准备的问答
查看>>
sql2012 ssrs_如何在SQL Server并行数据仓库中处理SSRS多值参数过滤
查看>>
使用Azure Data Studio在Docker容器上使用SQL Server 2017进行备份和还原操作
查看>>
使用sql语句生成报表_SQL Server报表服务:如何使用报表生成器处理常见的最终用户要求
查看>>
如何使用SQL Server 2016系统版本的时态表跟踪数据更改的历史记录
查看>>
sql语句集合里有集合_学习SQL:集合论
查看>>
mac命令行将输出写入文件_如何使用命令行将备份,文件和脚本迁移到云中/从云中迁移
查看>>
sql数据库性能指标_SQL Server磁盘性能指标–第2部分–其他重要的磁盘性能指标
查看>>
sql数据库性能指标_SQL Server磁盘性能指标–第1部分–最重要的磁盘性能指标
查看>>
SQL Server复制
查看>>
ssis zip压缩文件_SSIS平面文件与原始文件
查看>>
iif sql_SQL IIF语句概述
查看>>
mekko 教程_Power BI桌面Mekko图表
查看>>
SQL Server数据库快照
查看>>
sql 时态表的意义_SQL Server中的时态表
查看>>
activiti 功能概述_子串功能概述
查看>>