|
楼主 |
发表于 2016-11-18 10:31:20
|
显示全部楼层
对啊,我用input上传的,用平台提供那个不是还要改地址吗?我要上传到自己的后台上,- $("#imageFile").change(function() {
- var file = this.files[0];
- if (file.type.indexOf("image/") == -1) {
- this.files[0] = null;
- alert('请上传图片文件');
- return;
- } else {
- if (window.FileReader) {
- var reader = new FileReader();
- reader.onloadend = function(e) {
- };
- reader.readAsDataURL(file);
- }
- }
- var myFrom = new FormData();
- myFrom.append("file", file);
- myFrom.append("classId", $("#classId").val());
- var xhr = new XMLHttpRequest();
- xhr.open("POST", "http://rjm.com/class/UploadImage");
- xhr.send(myFrom);
- xhr.onreadystatechange = function() {
- if (xhr.readyState == 4 && xhr.status == 200) {
- var data = xhr.responseText;
- data = JSON.parse(data);
- console.log(data);
- sendMsg({
- type : 2,
- thumbnail : (STORAGESITE + data.file),
- file : data.file,
- width : data.width,
- height : data.height,
- isreply : isReply,
- reply : oldMsgInfo
- });
- }
- }
- });
复制代码
就是这样写的 |
|