上传图片有时候会弹出"HTTP错误"?

上传图片偶尔会提示"HTTP错误"
我是在一个页面,多个实例上传.大部数都可以正常上传,偶尔会有用户反映出现上述提示.我捕捉不到错误信息,不知道问题出在哪里.
JSP代码:

                <div class="upload">

<div class="container">

<div class="body">

<div class="col-md-12">

<div id="container5">

<input type="text" id="hkbzp_url" name="" value="图片地址(注:上传图片大小不能超过1M.)" readonly="readonly" class="inp_title js_content" style="width: 430px; float:left;" verify="no" maxlength="1000">

<p class="baseBtn" id="hkbzp" style="cursor:pointer;float:left; width:70px; text-align:center; line-height:24px; margin-left:10px; position:relative; overflow:hidden;">

上 传

</p>

<input type="hidden" id="hkbzp_img_url" name="hkbzp_img_url" value="" />

</div>

</div>

</div>

</div>

</div>

main.js代码:

var Qiniu5 = new QiniuJsSDK();

var option5 ={

runtimes: 'flash,html5,html4',

// runtimes: 'flash',

browse_button: 'hkbzp',

container: 'container5',

max_file_size: '1MB',

flash_swf_url: '/qiniu/js/plupload/Moxie.swf',

dragdrop: true,

chunk_size: '4mb',

uptoken_url: uptoken_url,

domain: domainUrl,

get_new_uptoken: true,

//unique_names: true,

save_key: true,

auto_start: true,

init: {

'FilesAdded': function(up, files) {

},

'BeforeUpload': function(up, file) {

},

'UploadProgress': function(up, file) {

},

'UploadComplete': function() {

///'#success'.show();

},

'FileUploaded': function(up, file, info) {

var jsonData = eval("(" + info + ")");

var fileUrl=domainUrl+jsonData.key;

$("#hkbzp_img_url").val(fileUrl);

$("#hkbzp_url").val(fileUrl);

alert("上传成功!");

},

'Error': function(up, err, errTip) {

alert(errTip);

}

}

uptoken代码:
public static String makeUptoken() throws Exception {

    String ACCESS_KEY =Setting.getQiniuAccessKey();

String SECRET_KEY = Setting.getQiniuSecretKey();

Mac mac = new Mac(ACCESS_KEY, SECRET_KEY);

String bucketName = Setting.getQiniuBucket();

PutPolicy putPolicy = new PutPolicy(bucketName);

// 可以根据自己需要设置过期时间,sdk默认有设置,具体看源码

//String key =getUUID()+"$(ext)";

String key =getUUID()+".jpg";

putPolicy.expires = 4600000;

putPolicy.scope=bucketName;

putPolicy.fsizeLimit=1*1024*1024;

//putPolicy.saveKey= getUUID()+"$(ext)";

putPolicy.saveKey= key;

//putPolicy.saveKey=getUUID();

//putPolicy.saveKey= DateUtil.formatter(new Date(), "yyyyMMddHHmmss")+"_$(fname)";

putPolicy.insertOnly=1;//默认0

//putPolicy.persistentOps="avthumb/flv/r/24/vcodec/libx264";

//putPolicy.persistentNotifyUrl="http://fake.com/qiniu/notify";

//putPolicy.mimeLimit="video/mp4;video/flv;video/swf";

//putPolicy.returnUrl = "http://localhost:80/qndemo/QiNiuCallback.jsp";//如不设置returnUrl,则直接将returnBody的内容返回给客户端

//putPolicy.returnBody = "{\"name\": $(fname),\"size\": \"$(fsize)\",\"w\": \"$(imageInfo.width)\",\"h\": \"$(imageInfo.height)\",\"hash\":$(etag)}";

String uptoken = putPolicy.token(mac);

return uptoken;

}

图片描述

以上是 上传图片有时候会弹出&quot;HTTP错误&quot;? 的全部内容, 来源链接: utcz.com/a/167307.html

回到顶部