Uploadify 不发送文件名

发布于 2024-09-11 18:07:30 字数 584 浏览 5 评论 0原文

我正在尝试使用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦言归人 2024-09-18 18:07:30

我正在使用 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请求)抛出异常{

        log.debug("========= upload file:" + file.getOriginalFilename());
}

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 {

        log.debug("========= upload file:" + file.getOriginalFilename());
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文