How can we upload images even if there is a concept called the same origin policy?

I am creating a small web application offline using HTML and JavaScript. A CSV file is used to store data.

To read CSV (using jquery-csv library), I use the following code.

<script>
    $(document).ready(function(){

        var filepath = 'data.csv';
        var data_string = $.get(filepath);
    });

</script>

But I can not read it because of an error.

XMLHttpRequest cannot load File: /// C: /Users/Nimal/Desktop/javascript-csv/data.csv. Cross-start requests are supported only for protocol schemes: http, data, chrome, chrome-extension, https


Then I could learn about the same concept of politics of origin.

Then I found many related articles here.

,

-. - , -, -, - .

.

<img src="abc.jpg">, .

?

, ?

, , .

-orgin-?

+4
1

, ( sop) . , . .

, sop : (scheme,host,port).

script, URL-. , . tuple_main. script URL-, URL-: tuple_request. :

1) tuple_main == tuple_request
 ===> OK  => get content

2) tuple_main != tuple_request
 ===> NOK => do not get content and show that sop is being violated.

DOM . , , . javascript. 10 javascript var foo . ...

Adobe Flash, MS Silverlight, javascript (, XMLHttpRequest) .. . Sop , -, , ( XSS)

( ):

CSV ( jquery-csv), .

<script>
    $(document).ready(function(){

      var filepath = 'data.csv';
      var data_string = $.get(filepath);
    });
</script>

- .

XMLHttpRequest :///C:/Users/Nimal/Desktop/javascript-csv/data.csv. - : http, data, chrome, chrome-extension, https

, sop. , , .

:

<img src="abc.jpg">, .

?

, (...) ( IE). sop, ​​ cross-origin. ():

  • -.

, HTTP .

" ", . , . :

  1. -

, csv. , - , , , ... " " ".

- jQuery (a script), script. . script, <script>.

. <img> . ( , ). .

<canvas>, , . script . .

IE? , - IE . " ", , IE -. , IE .

, . " ". (Ext js ), . , ( , tinypic, imageshack,...). -.

, - . . . . , , .

: , , - . sop , , . , . script , script...

csv, . , , , . .

, CORS. sop ( ).

+3

Source: https://habr.com/ru/post/1685645/


All Articles