Uploadify 不发送文件名
我正在尝试使用Uploadify上传多个文件,
$('#fileuploadinput').uploadify({
uploader: '/js/uploadify/uploadify.swf',
script: '/uploadpath',
cancelImg: '/js/uploadify/cancel.png',
multi: true,
fileDataName: 'uploadFile'
});
并且服务器端有一个带有comons-fileupload 1.2.1的Spring控制器。
for (org.apache.commons.fileupload.FileItem item : items) {
String name = item.getName();
// some other stuff
}
我需要获取上传文件的原始名称,并且使用标准输入标记时没问题 - 名称位于应有的位置,而 item.getName() 只是按预期返回它。但是,使用 Uploadify item.getName() 时返回 null。有没有办法得到名字?
I'm trying to use Uploadify for uploading multiple files,
$('#fileuploadinput').uploadify({
uploader: '/js/uploadify/uploadify.swf',
script: '/uploadpath',
cancelImg: '/js/uploadify/cancel.png',
multi: true,
fileDataName: 'uploadFile'
});
and there is a Spring controller with comons-fileupload 1.2.1 on the server side.
for (org.apache.commons.fileupload.FileItem item : items) {
String name = item.getName();
// some other stuff
}
I need to get the original name of the uploaded file, and it's fine when using standard input tag - the name is where it should be and item.getName() just returns it as expected. However, when using Uploadify item.getName() returns null. Is there a way to get the name?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我正在使用 Spring MVC,他们提供了一个包装类 org.springframework.web.multipart.MultipartFile
您可以使用方法 getOriginalFilename() 来获取文件名。
更多信息可以从 http:// /www.ke-cai.net/2010/12/file-upload-with-uplodify-and-spring.html
@RequestMapping(value = "upload", method = RequestMethod.POST)
公共字符串processUpload(@RequestParam MultipartFile文件,
ModelMap modelMap,HttpServletRequest请求)抛出异常{
I'm using Spring MVC, they provide a wrapper class, org.springframework.web.multipart.MultipartFile
you can use method, getOriginalFilename() to get the file name.
more information can be found from http://www.ke-cai.net/2010/12/file-upload-with-uplodify-and-spring.html
@RequestMapping(value = "upload", method = RequestMethod.POST)
public String processUpload(@RequestParam MultipartFile file,
ModelMap modelMap, HttpServletRequest request) throws Exception {