Thank you for your viewing. I am making an app for business name cards on Parse.com. So I want to save image file from HTML input to Parse DB, but I get the following console error from yesterday.
XMLHttpRequest cannot load https://api.parse.com/1/1/files/photo.jpg.
Response to preflight request doesn't pass access control
check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'https://***.***' is therefore not allowed access.
The response had HTTP status code 404.
OPTIONS https://api.parse.com/1/1/files/photo.jpg
dispatch @ parse-latest.js:8552
ajax @ parse-latest.js:8554
saveFile @ parse-latest.js:2483
save @ parse-latest.js:2401
(anonymous function) @ parse-latest.js:4478
wrappedResolvedCallback @ parse-latest.js:5292
(anonymous function) @ parse-latest.js:5353
runLater @ parse-latest.js:5337
then @ parse-latest.js:5352
(anonymous function) @ parse-latest.js:4477
save @ parse-latest.js:4475
save @ parse-latest.js:3828
cardMake @ ***.html:119
onclick @ ***.html:184
***.html:1
and here is my JS code.
function cardMake(){
var visualUpload = $("#inputVisual")[0];
var inputVisualFile = visualUpload.files[0];
var namePhoto = "photo.jpg";
var visualFile = new Parse.File(namePhoto, inputVisualFile);
var name = document.getElementById('inputName').value;
if (visualUpload.files.length > 0) {
if(name=="" || name==null) {
alert("記入していない項目があります。");
}else{
cardSave.set("mainVisual", visualFile);
cardSave.set("name", name);
cardSave.save(null, {
success: function() {
alert('新しい名刺を作成しました!');
}, error: function(error) {
alert('エラーコード: ' + error.description);
}
});
}
}else{
alert("Ooops! No visual file!");
}
}
and this is an HTML input
<input type="file" id="inputVisual">
I could save files on this code a couple of days before. So I get back to some old versions of my code for removing this bug, but that doesn't work.
Also I researched the following related Question but it didn't work.
How to save an Image in Parse.com via JavaScript?
And my site is using CloudFlare, though I don't know it is an relevant factor.
I really appreciate if anyone give me a solution. Thank you for your reading.