0

Im trying the dropzone to my Dropbox API and I was wondering how to pass the value of my ajax to my form action = "*" Because when I removed the action it said Dropzone : Uncaught Error: No URL provided But when I put my specific endpoint it said Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' but theres a Authorization in my ajax headers

This is my codes

<html>
<script src='//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js' type='text/javascript'></script>
<script src="https://rawgit.com/enyo/dropzone/master/dist/dropzone.js"></script>

<link rel="stylesheet" href="https://rawgit.com/enyo/dropzone/master/dist/dropzone.css">

<form action="https://content.dropboxapi.com/2/files/upload" type="file" id="files" name="files[]" multiple  class = "dropzone">


</form>



<script>

 function handleFileSelect(evt) {
 var files = evt.target.files; // FileList object

 // files is a FileList of File objects
 for (var i = 0, file_name; file_name = files[i]; i++) {

 $.ajax({
 url: 'https://content.dropboxapi.com/2/files/upload',
 type: 'post',
 data: file_name,
 processData: false,
 contentType: 'application/octet-stream',
 headers: {
 "Authorization": "Bearer ACCESS TOKEN",
 "Dropbox-API-Arg": '{"path": "/' + file_name.name + '","mode": "add"}'
 },
 success: function (data) {
    alert('The file has been uploaded!');

 console.log(data);

 },
 error: function (data) {
 console.log(data);
 }



 })

 }



 }

 document.getElementById('files').addEventListener('change', handleFileSelect, false);

</script>

</html>
  • Perhaps [this](http://stackoverflow.com/questions/35588699/response-to-preflight-request-doesnt-pass-access-control-check-angularjs) will help you – fumi_hwh Jan 24 '17 at 05:38
  • If I disable my CORS how can I access my Dropbox API without my Access token in my Authorization –  Jan 24 '17 at 06:55
  • [Browser-based JavaScript and CORS pre-flight requests from Dropbox](https://www.dropbox.com/developers/documentation/http/documentation), dose it help? – fumi_hwh Jan 24 '17 at 06:57

0 Answers0