play框架之文件上传
来源:互联网 发布:如何生成短信淘宝链接 编辑:程序博客网 时间:2024/06/02 02:33
<span style="font-size:18px;"><!DOCTYPE html><html><head><meta charset="UTF-8"><title>Insert title here</title></head><body> <form action="/upload.do" method="POST" enctype="multipart/form-data"> <input type="file" name="myfile"> <input type="submit"/> </form></body></html></span>
routes路由表 post /upload.do controllers.xxx.upload
后台实现:
<span style="font-size:18px;">public static Result upload() throws IOException{MultipartFormData body = request().body().asMultipartFormData(); FilePart filepart = body.getFile("myfile"); if (filepart != null) { String fileName = filepart.getFilename(); String contentType = filepart.getContentType(); File file = filepart.getFile();//获取到默认上传保存的完整文件路径,这只是个临时文件 BufferedInputStream is=new BufferedInputStream(new FileInputStream(file)); File newFile=new File("e://upload/"+filepart.getFilename());//要保存的文件路径 BufferedOutputStream os=new BufferedOutputStream(new FileOutputStream(newFile)); byte[] b = new byte[1024]; while(is.read(b)!=-1){ os.write(b); } is.close(); os.close(); return ok("File uploaded"); } else { flash("error", "Missing file"); return ok("aa"); }}</span>
0 0
- play框架之文件上传
- Play框架文件上传
- Play+scala上传文件
- Struts2框架之文件上传
- SpringMVC框架之文件上传
- play教程 第九课 play framework实现多文件上传
- php laravel 框架 之文件上传
- Struts框架之文件的上传
- java框架之struts2(文件上传)
- SSH框架之Struts的文件上传
- Struts1框架四之文件上传
- ssm框架练习之文件上传
- flask框架应用之--文件上传
- play framework实现多文件上传
- 来玩Play框架07 静态文件
- play!框架
- PLAY框架
- play框架
- JavaScript的对象举例
- 『java.util』 list 接口研究
- angular 国际化移动端可以使用
- cxf+Spring的webservice应用--拦截器
- Eclispe RCP开发中InvocationTargetException 分析流程
- play框架之文件上传
- moodle 3.0 怎么上传视频 并控制播放 videoeasy 插件
- iOS编译报:linker command failed with exit code 1 (use -v to see invocation)
- http_build_query函数带来的困扰
- Java学习笔记---多线程同步的五种方法
- 机器学习路线图
- android中左右滑屏的实现(广告位banner组件)
- java FTP 报错 Permission denied: recv failed 解决方法
- struct 互转 xml