-1

I am developing a website(B) which will manage content from and another site (A). The website(A) has many files in it's servers and website(B) knows the links to that files. Also website (B) will process the file before download to the user only by giving a title to the file.

The user will visit website(B), the website(B) will do some title operations to the file from website(A) and it will be deliver to the user.

The problem is that for a file, let's say 100mb

-with PHP, this data must pass through website website(B) in order to give only a title to that file, and i cannot find a methid that does not pass through the server as is server language.

-with JAVASCRIPT, we use client's resources instead of overloading the website(B) server but i cannot find a way to download a file with javascript as xmlhttprequest do not return a result as server may not allow it due sop.

So, I am thinking a way to process the file, Any ideas?

Stavros Koureas
  • 1,126
  • 12
  • 34
  • For some people that thinks this question for downvote, I want to add that the goal is to find a way that works like php so without limitations of the server sop and with client resources so without server bandwidth. – Stavros Koureas Nov 04 '16 at 20:20

1 Answers1

2

...but i cannot find a way to download a file with javascript.

It's called "ajax", the object is called XMLHttpRequest. Note that unless website(A) explicitly allows ajax requests from browsers showing pages in website(B) (via CORS), the calls will be rejected by the browser because of the Same Origin Policy.

T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875
  • Thanks for the response, i have read about XMLHttpRequest but this class isn't only for strings? Can i download large files even type is different? – Stavros Koureas May 22 '16 at 08:24
  • 1
    @s19k15: See [this question and its answers](http://stackoverflow.com/questions/7255719/downloading-binary-data-using-xmlhttprequest-without-overridemimetype). But before you worry too much about that, mind the note about the SOP. – T.J. Crowder May 22 '16 at 08:26
  • Thats correct, the most webservers are protected using sop, so how can i do that? – Stavros Koureas Oct 06 '16 at 21:54