Environment:
html5
JavaScript
Angularjs
node.js
express.js
Couchbase
Question:
I understand the concerns and security measures implemented within the web environment to prevent the display of directory paths to the world. However, I have an issue that requires knowing the full directory path to a selected file.
I am building a web page for an internal website. The web page needs to allow the user to select a tab delimited file. This tab delimited file will exist on a network server, which is a policy instituted by the company and mandated by external auditors. This file may exist for various clients, with data specific to the client. With that said, the files will reside within different folder structures on the server(s). The user wants to pick the appropriate file and have the data uploaded to the database. Based on the size of the file (up to 10’s of millions of rows), the user does not want to wait for the web page to process immediately. Therefore, the solution is to create a task. The task will contain all the parameters necessary to manipulate the data prior to uploading the data to the database. I understand the simple solution is to upload the file to a common directory but that is not practical. As the user could set up several tasks that will upload the same tab delimited file to the database using different parameters.
I would like to have my task creation process contain the file name with the directory structure. When the background process executes the task, it can extract the data from the original location. Additionally, if I have multiple tasks extracting the same data, I not concerned I may have multiple copies of the data present.
I will appreciate any help with code snippets, website, etc. that may suggest methods to resolving this issue. Please not, that at the current moment, PHP is not an option. A management decision prevents the use of PHP.
TIA
Anthony
It is not exactly possible, so I see two solutions. One is to try and get the path to the temporary location of the file, rather than the actual permanent location.
Suppose your has an id of fileInput and you're using jQuery:
$('#fileInput').change( function(event) {
var tmppath = URL.createObjectURL(event.target.files[0]);
console.log("Temporary Path(Copy it and try pasting it in browser address bar):"
console.log(tmppath);
});
Otherwise I would just make a separate input for path, and show a brief instruction to users on how to copy-paste the URL from their Windows Explorer window.
Related
I am soon to be building a node application which involves allowing the user to fill in a form and then save this information to a mongo database. As part of this process, the user needs to be able to upload multiple images related to the form data. The user will need to see a small preview of each image (along with ability to remove images) before submitting the form which saves the data to an object then uploads the images to the server.
I do not want to save the images to the database (but do on the server), but I do want to save their file paths to the related object. This is the first ever solo project I will be working on for a web build for a friend of mine so its really early days with my experience with Node. I am aware I have thrown myself in the deep end but am determined to succeed with this project.
My question to you all is: is this possible with node? If so, could someone give me some pointers on how to approach this i.e. any useful npm packages etc etc. Note: I am only looking for help with regards to the server side, not front-end. I hope I have not been too vague; thank-you all in advance.
I want to make a code using only JavaScript or/and jQuery to access a static directory and retrieve the names of some icons i saved there (SVG icons) and display the names to the user. i couldn't do that with the file api and i have no idea where to start.
I'm going to assume from your mention of jQuery and the File API that you're trying to do this within a browser.
You can't. It just isn't allowed, there is no mechanism to provide it.
If you're in control of the machine where you want this information to be accessed, you can run a server process on it that can do that; code in the browser can then make a request to the server code to request the information. But there's no browser-only way to do it.
I'm working on a website that is going to be offline. All the html files will be in a folder stored on the hard-disc. I've managed to do 90% of the work and the last part I have no idea of. Here is what it is:
I have stored a list of products in the localStorage as various strings under the keys - like buying objects and it goes to the cart, the cart objects are in localStorage. I created a page that showed the list of all the products in the localStorage. It can be cleared if the user clears them. Now I need to create a page where all the objects that was selected before, regardless of the localStorage being cleared, show as list in this page. You can take it as the page that lists products that have been ordered in the past, i.e even after the cart is cleared the products will show in the past-orders page.
I do not know any server side codes, I did everything using JavaScript as it was supposed to be a simple project, but I'm stuck at this part. So I cannot use PHP or anything to generate files or use a database to store stuff.
Here's what I thought but I don't think it works but wanted to confirm if it does or not:
Generate an XML file or a .txt file and store it in the drive and then clear the localStorage. But I don't think it is possible. If its possible just using JavaScript please point me in the right direction and I'll research and come up with something.
P.S. the website will be entirely offline what I mean is the users will never connect to the internet for this to work. Also there won't be a server or localhost.
Thank you!
The site is completely offline, but functionality is similar to an eCommerce site. You click a button and some content from the website stores in the localStorage and I have to call it in multiple pages, when a user clicks another button, localStorage clears but whatever was selected before must be available without localStorage. Hmmmm.. Consider a quiz site where you answer everything and when you take a new quiz, old scores will be stored somewhere else and it won't change when you take a new test.
Is it possible to attain this functionality without a server side script? It seems the final-targeted-users won't know how to install any softwares that can provide a localhost or a server or something like that.
Client-side, browser's JavaScript runtimes don't have local file system access excepting a very limited one when uploading files to a remote server, and anyway, browers won't give you direct access to the file.
You'll need some kind of server-side logic behind the scenes if you want full I/O in the local file system.
Perhaps you can take a look at NodeJS, a server-side JavaScript runtime that can work as lighty Web server on either small and large projects, and it has built-in server-side JavaScript I/O functions.
Otherwise, you're absolutely stuck in the client-side Web browser's sandbox limitations.
U can refer documents of knockoutjs and NodeJS.. That would probablky help... A far as my knowledger is concerned NodeJS does contain a way to handle your problem.
I am doing a spring MVC project and now I want to create a file path chooser.I am trying to give users the ability to choose a location in order to save their file. For eg, C:\testlocation\sublocation... I came across many posts that said it is impossible, as this could pose as a security threat. However, I am still curious to know if there is an alternative.
I believe you're mixing two different functional requirements:
Being able to provide a file download with Save As dialog.
Being able to preset the default file location in Save As dialog so that the enduser doesn't need to browse the right folder first (e.g. "C:\foo\bar" instead of "C:\Users\John\Downloads").
The first is very easily possible by returning the whole file in HTTP response body along with this header:
response.setHeader("Content-Disposition", "attachment;filename=\"filename.ext\"");
The second is impossible as you figured based on the answers you found.
I need to fetch complete the path from file select element of HTML using JavaScript. I have returned a JavaScript function, but it fetches only file name not the complete path.
How can I get the complete file path?
You can't. It's due to security. The browser only provides the content and the filename.
Providing the path could allow an attacker to learn things about the files on your hard drive that they want kept private. Do you really want to let the web server know that the kitty.png you are uploading for your avatar was actually in c:/pr0n/?
No, I didn't think so.