Tag: file

how to read a text file using Javascript

I am taking a text file from user and then posting that file back to the browser using ajax storing the content in db and then showing the content back to user page using Jquery post response. Now i want to something like this.. Read the text file from the user computer using javascript. Display […]

How to execute javascript in different file?

I have multiple javascript functions in my html page. One of them, by far the biggest, is executed on a button click. If I moved that function into a separate .js file, what would be the syntax to have the onclick run that file?

Node.js file transfer using UDP

I’m trying to create a simple Node.js server that receives files from clients via UDP. The problem I’m having is that every time I try to transmit a large file (anything over 100kb), the server doesn’t seem to respond. So far I’ve been successful at transmitting files up to 50kb. Is there any way to […]

why does “HTML file select” changes the order of selected files and sort them alphabetically?

I am trying to get the name of the files that are selected by a “file” input in HTML: <input type=”file” class=”filestyle” name=”file-select[]” id=”file-select” accept=”image/*” multiple> I wrote this JavaScript code to do that: $(‘#file-select’).on(“change”, function(){ var selectedFiless = this.files; for (var i = 0; i < selectedFiless.length; ++i) { var name = selectedFiless.item(i).name; alert(name); […]

How to store a JSON file into a variable using Javascript native

I’ve been trying to store the data from a JSON file into a variable in Javascript and everything were good until the JSON.parse function didn’t work. My file is called test.json and it looks like this: { test: ‘Hello World!’ } I also tried changing it to: { test: ‘Hello World’ } My javascript code […]

JavaScript – extract folder names

I’m fairly new to JavaScript. Given a local machine’s folder path (Windows), I was wondering how you can extract the names of all the possible folders in the current path, without the knowledge of how many folders there are or what they are called. Thank you very much in advance.

Write a file with Prototype or plain Javascript

I know the question has been asked thousands of times, but I’ll ask it again: is there a way (even patchy) to write/read a dumb text file with Javascript or Protoype ? This is only for debug purposes, and is not designed for production. The thing is I need it to work with (at least) […]

How do I get browser to prompt user to save a file dynamically generated by server?

Clients submit post requests using jquery ajax as illustrated below: $.ajax({ url: “/xxx?request1”, data: theParams, type: ‘post’, error: function(XMLHttpRequest, textStatus, errorThrown){ // error handling }, success: function(data){ var theResult = JSON.parse(data); // success handling } }); Apache is configured to pass requests with /xxx? to a custom app. The app processes the request and returns […]

Javascript in html write to file

I am trying to write to a file from an html form, however the write part of the javascript doesn’t do anything… Only the validate part of the script seems to be working… **How much do I have to write in order for stackoverflow to allow me to post something ? “It looks like your […]

How can I check existence of a file with JavaScript?

How can I check an existence of a file (It is an xml file that I would like to check in this case) with JavaScript?