html文件无法上传,关于html上传文件的问题

第一种是:jquery+ajax,每次上传的时候,显示这个错误,是不是我的url写得有问题,应该怎么写

Failed to load resource: the server responded with a status of 405 (Not Allowed)

index.html:1 XMLHttpRequest cannot load http://localhost/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. The response had HTTP status code 405.

下面是我的代码

$(".loading").show(); //显示加载图片

//发送数据

$.ajax({

url:'http://localhost',

type:'POST',

data:data,

cache: false,

contentType: false, //不可缺参数

processData: false, //不可缺参数

success:function(data){

data = $(data).html();

//第一个feedback数据直接append,其他的用before第1个( .eq(0).before() )放至最前面。

//data.replace(/</g,'') 转换html标签,否则图片无法显示。

if($("#feedback").children('img').length == 0) $("#feedback").append(data.replace(/</g,''));

else $("#feedback").children('img').eq(0).before(data.replace(/</g,''));

$(".loading").hide(); //加载成功移除加载图片

},

error:function(){

alert('上传出错');

$(".loading").hide(); //加载失败移除加载图片

第二个问题是类似的:也是没有上传成功,我只需要有一个能上传成功就行了,我觉得可能是我的url有问题,但这就是我的ip地址

错误显示:

Failed to load resource: the server responded with a status of 403 (Forbidden)

index.html:1 XMLHttpRequest cannot load http://192.168.1.137/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. The response had HTTP status code 403.

我的代码如下:

var xhr = new XMLHttpRequest();

.....(中间代码省略就不贴上来了)

xhr.open('post', 'http://192.168.1.137',true);

xhr.onreadystatechange = function () {

alert(xhr.readyState);//FF下会依次是1,2,3,4但最后还会再来个1

//IE下则是1,1,3,4

};

xhr.send(fd);

假设我的ip地址为192.168.1.xxx,然后我想把文件传输到我的/home/hhh/aaa目录下,我应该怎么写url

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值