By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,946 Members | 773 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,946 IT Pros & Developers. It's quick & easy.

browse for file in javascript?

P: 3
I have a script that replaces the content of a container on a webpage. What I would like to do is browse to a file and select it. What I do now is type the info in but would like to automate it more. In asp I can browse to a file from my admin page select the file and it posts the first few lines of the text with a more link. can I do this in javascript?
Jul 26 '13 #1
Share this Question
Share on Google+
3 Replies


Dormilich
Expert Mod 5K+
P: 8,639
are you talking about files on a server or files on your local machine?

for the former, you need a server side language for assistance, for the latter, hm, not through the browser. but tdifferent OSís have the possibility to write desktop apps in JS.
Jul 26 '13 #2

P: 3
On my webserver. It is in my home but I get to it by www. Can't I browse for a file in java script. Maybe something like this
Expand|Select|Wrap|Line Numbers
  1. function openfile(file) {
  2.  
  3. window.location = "file:///" + file;
  4.  
I Know it has this
Expand|Select|Wrap|Line Numbers
  1. <input type="file"> 
but not sure how to work it.
Maybe I am going at this wrong? I have a script that changes the text in a container on my webpage but I have to navigate to the folder and open the script and type in the text hit a button that changes the text. If I have 6 text areas about 6 things I do it 6 times. I want to do this from 1 page instead of 6.
Jul 26 '13 #3

Dormilich
Expert Mod 5K+
P: 8,639
On my webserver.
client-side JavaScript cannot do work on the server, period. (think of what would happen if you (resp. anyone else) could)

Expand|Select|Wrap|Line Numbers
  1. function openfile(file) {
  2. window.location = "file:///" + file;
that is not related to a webserver (they use HTTP), however, check out the FileReader API.
Jul 26 '13 #4

Post your reply

Sign in to post your reply or Sign up for a free account.