?
Solved

curl javascript equivalent

Posted on 2014-08-12
7
Medium Priority
?
726 Views
Last Modified: 2014-08-15
Right now I have a script that download a file via PHP CURL. I was wondering if there is a javascript equivalent to curl from which a download can be initiated as coming from the local browser and not the server itself? I would also need to gather stats similar to curl info.
0
Comment
Question by:ITNC
  • 4
  • 3
7 Comments
 
LVL 58

Assisted Solution

by:Gary
Gary earned 2000 total points
ID: 40256371
Using jquery it is easily possible
https://github.com/johnculviner/jquery.fileDownload

Using plain js would be a major PITA
What kind of stats - this isn't anything like curl
0
 

Author Comment

by:ITNC
ID: 40256395
I was hoping to at least get the download size and speed. Those two are a must. I was looking through the documentation and so far I haven't seen if that is possible.
0
 
LVL 58

Expert Comment

by:Gary
ID: 40256457
This maybe better handled through an ajax request to your server that uses curl and returns the data.
You can get the header, as for download speed
http://www.smashingmagazine.com/2011/11/14/analyzing-network-characteristics-using-javascript-and-the-dom-part-1/
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:ITNC
ID: 40256474
That is actually my current setup. The thing is I need the request to come from the client machine so it is routed in through the LAN port of my pfsense router and then out the WAN. Apache is running on the pfsense router so when it makes the request with this current setup it is not routed through the LAN. If that makes any sense haha it's hard for me to give many more details.
0
 
LVL 58

Expert Comment

by:Gary
ID: 40256558
What will happen to the downloaded file?
0
 

Author Comment

by:ITNC
ID: 40256565
after download it can be discarded, the stats are what I need to collect.
0
 
LVL 58

Accepted Solution

by:
Gary earned 2000 total points
ID: 40256580
I think this is beyond the scope of javascript with any degree of reliability, this is more in the realms of Java
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question