1
我面对这个问题:否“访问控制允许来源”
的XMLHttpRequest无法加载 http://localhost:8000/scripts/advaced_donwload/advancedUpload/vueupload/store.php。 请求的 资源上没有“Access-Control-Allow-Origin”标题。 'http://localhost:8080'因此不允许 访问。
这是我的代码:
storeMeta(file) {
var fileObject = this.generateFileObject(file)
return new Promise((resolve, reject) => {
this.$http.post('http://localhost:8888/vueupload/store.php', {
name: file.name
}).then((response) => {
fileObject.id = response.body.data.id
resolve(fileObject)
},() => {
reject(fileObject)
})
})
}
报头(“内容类型:应用程序/ JSON”); header('Access-Control-Allow-Origin:http:// localhost:8080'); header('Access-Control-Allow-Headers:Origin,X-Requested-With,Content-Type,Accept'); $ id = uniqid(true); // http_response_code(500) 回波json_encode([ \t '数据'=> [ \t \t \t的 'id'=> $ ID \t \t] \t]); –
这是行不通的 –
尝试完全禁用'CORS',你使用哪个PHP服务器/框架? – Bamieh