Reputation: 19
I face this problem:
XMLHttpRequest cannot load http://localhost:8000/scripts/advaced_donwload/advancedUpload/vueupload/store.php. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.
This is my code:
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)
})
})
}
Upvotes: 1
Views: 945
Reputation: 10906
your php server must allow http://localhost:8080
to POST
resources. this is done in the server configuration.
Or you can add this header for the server:
Access-Control-Allow-Origin: http://localhost:8080
Or just allow everything
Access-Control-Allow-Origin: *
To do it in on a PHP
server, it might be something simple like this:
<?php
header("Access-Control-Allow-Origin: *");
if you are using a framework such as laravel or such, check their documentation in the CORS
sections
Upvotes: 1