|
楼主 |
发表于 2017-4-27 11:01:33
|
显示全部楼层
我的js文件是这样写的
var uploader=WebUploader.create({
server: "http://172.18.5.216:80/x5/UI2/KMS/common/actions/FileUpload.j",
/* formData :{
"params" : params
},*/
auto: true,
chunked : true,//是否分片上傳
chunkSize : 1024000,
threads : 1,//并发数量
duplicate : true, //是否去重
fileSingleSizeLimit : 1024*1024*1024*4,//限制大小4G
pick : '#WebUploader_id',
resize : false
});
后台的.j文件是这样
public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException
{
response.setHeader("Access-Control-Allow-Origin", "*");
response.setHeader("Access-Control-Allow-Methods", "*");
response.setHeader("Access-Control-Allow-Headers", "x-requested-with,content-type");
response.setCharacterEncoding("utf-8");
DiskFileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload sfu = new ServletFileUpload(factory);
sfu.setHeaderEncoding("utf-8");
String savePath = "D:\\KMS1.1\\TEST";
String folad = "uploads";
savePath = savePath + "\\"+folad+"\\";
String fileMd5 = null;
String chunk = null;
try {
List<FileItem> items = sfu.parseRequest(request);
for(FileItem item:items)
{
if(item.isFormField()){
String fieldName = item.getFieldName();
if(fieldName.equals("fileMd5")){
fileMd5 = item.getString("utf-8");
}
if(fieldName.equals("chunk")){
chunk = item.getString("utf-8");
}
}
else
{
File file = new File(savePath+"/"+fileMd5);
if(!file.exists()){
file.mkdir();
}
File chunkFile = new File(savePath+"/"+fileMd5+"/"+chunk);
FileUtils.copyInputStreamToFile(item.getInputStream(), chunkFile);
}
}
} catch (FileUploadException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
X5另一个应用访问我的.j时就会报 501 (尚未实施) 服务器不具备完成请求的功能。
如果js和.j在同一个X5服务下就没有问题。
如果js是在另一个X5服务下 就会报 501 (尚未实施) 服务器不具备完成请求的功能。
这个该怎么解决?
|
|