NutzCN Logo
精华 uploadify 上传图片
发布于 3211天前 作者 javanan 2442 次浏览 复制 上一个帖子 下一个帖子
标签:

js代码--------啪啪啪---

$(window).ready(function(e) {

	// uploadify插件 上传本地图片
	 $('#file_upload').uploadify({
         'swf':'file/uploadify.swf',
         'uploader': '../../qijule/imageuploadmodule/upload',
         'buttonText':'',
         'fileTypeDesc':'图片(gif,jpg,png,jpeg)',
         'fileTypeExts':'*.gif;*.jpg;*.png;*.jpeg',

         'onUploadSuccess':function(file,data,response){
             data=JSON.parse(data);
             if(data.errorCode==0) {
                 //上传成功之后,展示图片
                 $("#upload_img").attr("src", data.url);
                 $("#article_picture").attr("value", data.url);
                 $(".pic-msg .errormsg").html("");
                 $("#select-picture").modal("hide");
             } else {
                 alert(data.msg);
             }
         },
         'onUploadError':function(file,errorCode,errorMsg,errorString){
             alert('Error: '+errorString);
         }
     });
});

java代码-----啪啪啪

@At("/upload") @AdaptBy(type = UploadAdaptor.class, args = { "ioc:myPicUpload" }) @POST public NutMap uploadHead(@Param("file") TempFile tf, AdaptorErrorContext err, @Attr("adminid") String adminid) { if (adminid == null) { return RetMessage.retFailMsg(FailType.unline); } if (err != null && err.getAdaptorErr() != null) { return RetMessage.retFailMsg(FailType.filesize); } else if (tf == null) { return RetMessage.retFailMsg(FailType.filenull);///----文件空 }

啪啪啪啪 文件上传到了 临时文件,,但是后天提示文件是null的   也就是 file没有拿到临时文件
有用过  uploadify 的吗
怎么设置这个 名字?
3 回复

看日志里面的名字

@wendal
日志是这样的

2016-01-31 20:11:39,967 [http-apr-8080-exec-3] DEBUG org.nutz.mvc.upload.UploadAdaptor - Select Html4 Form upload parser --> /qijule/imageuploadmodule/upload
2016-01-31 20:11:39,973 [http-apr-8080-exec-3] DEBUG org.nutz.mvc.upload.FastUploading - FastUpload : /imageuploadmodule/upload
2016-01-31 20:11:39,974 [http-apr-8080-exec-3] DEBUG org.nutz.mvc.upload.FastUploading - info created
2016-01-31 20:11:39,975 [http-apr-8080-exec-3] DEBUG org.nutz.mvc.upload.FastUploading - Params map created - 0 params
2016-01-31 20:11:39,977 [http-apr-8080-exec-3] DEBUG org.nutz.mvc.upload.FastUploading - boundary: 
------------ei4Ef1gL6ae0ei4KM7GI3ei4ei4GI3
2016-01-31 20:11:39,985 [http-apr-8080-exec-3] DEBUG org.nutz.mvc.upload.FastUploading - skip first boundary
2016-01-31 20:11:39,985 [http-apr-8080-exec-3] DEBUG org.nutz.mvc.upload.FastUploading - Reading...
2016-01-31 20:11:39,986 [http-apr-8080-exec-3] DEBUG org.nutz.mvc.upload.FastUploading - Upload File info: FilePath=[null],fieldName=[Filename]
2016-01-31 20:11:39,986 [http-apr-8080-exec-3] DEBUG org.nutz.mvc.upload.FastUploading - Found a param, name=[Filename] value=[original_fwwc_9e1b000084551e83.jpg]
2016-01-31 20:11:39,987 [http-apr-8080-exec-3] DEBUG org.nutz.mvc.upload.FastUploading - Upload File info: FilePath=[null],fieldName=[from]
2016-01-31 20:11:39,987 [http-apr-8080-exec-3] DEBUG org.nutz.mvc.upload.FastUploading - Found a param, name=[from] value=[localhost:8080]
2016-01-31 20:11:39,987 [http-apr-8080-exec-3] DEBUG org.nutz.mvc.upload.FastUploading - Upload File info: FilePath=[original_fwwc_9e1b000084551e83.jpg],fieldName=[Filedata]
2016-01-31 20:11:39,988 [http-apr-8080-exec-3] DEBUG org.nutz.mvc.upload.FastUploading - Upload Info: name=original_fwwc_9e1b000084551e83.jpg,content_type=application/octet-stream
2016-01-31 20:11:40,004 [http-apr-8080-exec-3] DEBUG org.nutz.mvc.upload.FastUploading - Upload File info: FilePath=[null],fieldName=[Upload]
2016-01-31 20:11:40,004 [http-apr-8080-exec-3] DEBUG org.nutz.mvc.upload.FastUploading - Found a param, name=[Upload] value=[Submit Query]
2016-01-31 20:11:40,005 [http-apr-8080-exec-3] DEBUG org.nutz.mvc.upload.FastUploading - ...Done 218136 bytes readed
2016-01-31 20:11:40,008 [http-apr-8080-exec-3] DEBUG com.qujule.mvc.LogTimeProcessor - [POST]URI=/qijule/imageuploadmodule/upload 46ms

我把
@Param("file") TempFile tf 改为 @Param("Filename") TempFile tf 还是不行

可以了
- Upload File info: FilePath=[original_fwwc_9e1b000084551e83.jpg],fieldName=[Filedata]

是 Filedata

添加回复
请先登陆
回到顶部