`
Silmon
  • 浏览: 54548 次
  • 性别: Icon_minigender_1
  • 来自: 郑州
社区版块
存档分类
最新评论

UpLoadForm

阅读更多

upload.jsp

<html:form action="/upLoad" method="post"enctype="multipart/form-data">
			fileName : <html:text property="fileName" />
		
			<br />
			fileContent : <html:file property="fileContent" />
		
			<br />
			<html:submit />
			
		</html:form>

 

UpLoadAction.java

public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		UpLoadForm upLoadForm = (UpLoadForm) form;// TODO Auto-generated
		// method stub
		FormFile ff = upLoadForm.getFileContent();
		String filename=ff.getFileName();
		System.out.println(ff.getFileName() + ff.getContentType());
		System.out.println(getServlet().getServletContext().getRealPath("/"));
		  try {
			OutputStream outputStream = new FileOutputStream(new File("c://" + ff.getFileName()));
			  byte b[]=ff.getFileData();
			  outputStream.write(b);
			  outputStream.close();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

 

 

分享到:
评论

相关推荐

    UploadForm.js:用于上传表单数据的 Javascript 插件,包括具有 XHR2 和 IFrame 回退的文件

    script src =" UploadForm.js " &gt; &lt;/ script &gt; #用法 ###例子 var uploadForm = new UploadForm ( 'form' , 'https://cross-domain.com/upload' , { type : 'json' , // 'text', 'json', 'xm

    浮点vfdsfJAVA实现链表,双向链表.txtJAVA实现链表,双向链表.txt

    &lt;form id="uploadform" name="uploadform" action="/upload/do_upload" enctype="multipart/form-data" method="POST" onsubmit="return false;"&gt; &lt;!-- left upload --&gt; &lt;colgroup&gt;&lt;col...

    struts1.2文件上传demo

    UploadForm uploadForm = (UploadForm) form; File file = uploadForm.getUploadedFile(); String fileName = uploadForm.getFileName(); // 保存文件到服务器 saveFile(file, fileName); return mapping....

    struts 文件上传实例

    UploadForm uploadForm = (UploadForm) form; File uploadedFile = uploadForm.getFile(); String fileName = uploadForm.getFileName(); // 验证文件大小和类型 // ... // 保存文件到服务器 File ...

    fileupload

    UploadForm uploadForm = (UploadForm) form; DiskFileItemFactory factory = new DiskFileItemFactory(); ServletFileUpload upload = new ServletFileUpload(factory); try { List&lt;FileItem&gt; items = ...

    Struts上传,已经处理好乱码问题

    UploadForm uploadForm = (UploadForm) form; DiskFileItemFactory factory = new DiskFileItemFactory(); // 设置临时目录 factory.setRepository(new File(System.getProperty("java.io.tmpdir"))); ...

    用Struts上传多个文件的方法(含源码)

    UploadForm uploadForm = (UploadForm) form; FormFile file1 = uploadForm.getTheFile(); FormFile file2 = uploadForm.getTheFile2(); // 文件保存逻辑 String savePath = "/path/to/save/files"; saveFile...

    struts_fileUpload用例

    UploadForm uploadForm = (UploadForm) form; File file = uploadForm.getFile(); String fileName = uploadForm.getFileName(); // 进行文件处理... } ``` 2. **文件处理**:你可以选择将文件保存到服务器...

    最新strugs1.2文件上传demo,经过修改此demo绝对无误

    UploadForm uploadForm = (UploadForm) form; FormFile file = uploadForm.getFile(); // 获取文件名、类型、大小等信息 String fileName = file.getFileName(); String contentType = file.getContentType();...

    upload文件上传

    UploadForm uploadForm = (UploadForm) form; FormFile file = uploadForm.getFile(); // 获取文件名、文件大小等信息 String fileName = file.getFileName(); int fileSize = file.getFileSize(); // ...

    Struts 1.XX <html:file>的使用

    UploadForm uploadForm = (UploadForm) form; File file = uploadForm.getUploadFile(); String fileName = uploadForm.getUploadFileFileName(); // 验证文件大小、类型等 // ... // 保存文件到服务器 ...

    利用struts标签上传的简单例子

    UploadForm uploadForm = (UploadForm) form; File uploadedFile = uploadForm.getFile(); String fileName = uploadForm.getFileName(); // 实现文件保存的逻辑,例如: saveFile(uploadedFile, fileName); ...

    Struts1实现文件上传源码

    UploadForm uploadForm = (UploadForm) form; File uploadedFile = uploadForm.getFile(); String fileName = uploadForm.getFileName(); // 检查文件大小,类型等 // ... // 保存文件到服务器 File ...

    strucs上传图片

    UploadForm uploadForm = (UploadForm) form; File uploadedFile = uploadForm.getFile(); String fileName = uploadForm.getFileName(); // 文件保存逻辑,如移动到服务器指定目录 File targetFile = new ...

    struts文件上传例子

    UploadForm uploadForm = (UploadForm) form; FormFile file = uploadForm.getFile(); // 验证和保存文件 // ... return mapping.findForward("success"); } } ``` 5. **文件保存**:使用Apache Commons ...

    struts1.2实现动态多文件上传

    UploadForm uploadForm = (UploadForm) form; FormFile[] files = uploadForm.getFiles(); for (FormFile file : files) { // 处理每个文件,如保存到服务器、检查文件类型等 } // 返回成功或错误的页面 } ...

    struts 上传组件使用方法

    UploadForm uploadForm = (UploadForm) form; FormFile file = uploadForm.getFile(); // 获取文件名、大小等信息 String fileName = file.getFileName(); int fileSize = file.getFileSize(); // 将文件...

    用struts上传多个文件的方法

    UpLoadForm uploadForm = (UpLoadForm) form; FormFile file = uploadForm.getTheFile(); FormFile file2 = uploadForm.getTheFile2(); // 进行文件保存等逻辑处理 // ... // 返回结果页面 return mapping...

    struts框架中formFile批量上传图片

    UploadForm uploadForm = (UploadForm) form; for (FormFile file : uploadForm.getFiles()) { // 获取文件名、类型等信息 String fileName = file.getFileName(); String contentType = file.getContentType()...

Global site tag (gtag.js) - Google Analytics