How to get folder path instead of file path in extjs - javascript

How to access path of a folder instead of a file using Ext.form.field in extjs. Is it possible at all in extjs.
I can use the component above but its giving me only the file name without the path to the file.
Or should I use third party tools like jquery or maybe dynamic html/ plain js?

There's no way to get any information on the client's filesystem using a website, for security reasons. Nor Javascript, nor PHP...
Thus, you can't get the path of a client's file.
However, you can do it with a non-website application, installed on his computer.

You could use a java, flash, or activex control to do that.
You could also host extjs inside Sencha Desktop Packaging, ie in an installed executable with an embedded browser.
You might be able to get folder access with HTML5, but that would only be a folder local to your domain and heavily restricted.
Otherwise, browser file/folder security restrictions exist for good reason and you should consider files off limits other than upload/download.

Related

Modify a local file with Javascript

I must make a local app with an interface. This app should load text files, modify them, and save them.
I made the interface with html/css/js, and the core of the app was made with js only.
Currently, I load the file with an input, but to save it, the browser makes me download it. I know this is a security measure.
This app is not going to be put online.
My question is : what can I do to replace directly the loaded file by the new one ?
Can I use my app (html/css/js) without a browser ?
Is there a browser that allows me to edit my local files directly ?
Is there any solution I can't think of ? Using another language to communicate with the js maybe ?
Thanks.
If you don't need your app to be online, with Electron you can make an executable using your existing code (you will have change how you're going to save the file using Electron APIs).
Being a program running on your system, you'll be able to save directly on the file system.
JS in the browser is not able to edit local files, because of security.
If you want to, you can use Node.js, a Desktop/Server Framework, which uses JS.

Search string in a directory jquery

I am novice in javascript. Is it possible to search in a directory of html files for a text content or string?
If possible can anyone suggest me how to implement this or any reference.
JavaScript has no native ability access files or directories. You need an API provided by the host environment to do that.
NodeJS, for example, provides the File System module.
JavaScript embedded in a webpage has no access to the client's file system (for security reasons). It can access URLs (via XMLHttpRequest) which a web server can map onto a file system.
Well yes it is possible. But modern browsers will restrict access to the client's disk so no you will not be allowed to read the disk without serious changes in browser specific security settings.

Access local files from HTML5 Desktop Application in html folder

HTML5 is great and I can replace my existing desktop application with it, but just a little security restriction prevents me to complete my job. I plan to create a simple desktop application completely with HTML5 so it can run on any mobile and desktop devices that support HTML-5.
I know about the browser security on local file and the reason behind it, but I don’t know why I couldn’t find a way to grant read-only access to a folder as sandbox. My application does not need to write a file or even does not need to read a file outside of It main html folder. It needs to read the local file just in same folder same as it do on domain.
So please let me know:
Can run browser with specific command to force it grant access to local file that exists in same folder of HTML? It should not disable all local security restriction just grant HTML access to file in same folder or subfolder.
Is it cross platform method to map a local folder as local host that work on mobile platforms?
Is there any manifest file exists to put in folder to grant read access in same HTML folder?
Is there any way to grant read-only access to a folder as sandbox?
Note: I don't want use third party solution such as XULRunner, Mozilla Prism, Adobe Air or any other third party, I need HTML-5 solution to be cross platform if there is any.
Any idea is welcome.
If you need that file so much, why not just load it dynamically inside a JS script as a json object.
So, in other words, put the contents of the file into a js script, and strucutre the file contents into JSON format, then load that script on load or when you require it.
Alternately if you need file IO use localstorage.
according to this site, launching chrome from the cmd with the parameter --allow-file-access-from-files will disable this security feature

List contents of a directory via HTML/JavaScript on a local machine

I'm making a "Jeopardy" board in HTML/JavaScript/XML. I want this app to be able to run on a local machine without having Apache or IIS installed. I figured we'd use a different XML file for each different round. So I figured I would need a way to specify which file to use. To do this, the most user-friendly way would be to list which XML files already exist in the directory, and list those in an HTML select-box, and let the user choose.
However, I'm stumped as to how to get the list of filenames in a specific directory. I could easily do it with PHP, but as I said before, I want it to work without Apache or IIS, and IE just plain sucks with their non-standards compliant BS, so I would really like not to be forced to use it for its FileObjectSystem ActiveX control.
Anyone know any other way of getting the folder contents into a JavaScript array?
The only thing I can think of would be to use Adobe AIR or Titanium Desktop for desktop File I/O with JavaScript using no server back-end.
It's not a select-box, but the easiest way should be the use of a file-input. It allows the user to select a file from the local machine, and it allows your application to retrieve the path of the file that has been selected.
Assuming windows: FileSystemObject also works without IE, so if you use a jscript/vbscript for starting your application, you can first create a javascript-file containing an array with the available xml-files, and then run the application(document) with the default-browser.
I donno what is Jeopardy. However my 2 cents
If the XML content of the files is what you are really interested in you can define javascript variables to store XML and then use the XMLHttpRequest or ActiveXObject("Microsoft.XMLHTTP") depending on the browser to parse and process the XML.
You could look into the directory listing output. I believe this varies by browser however and would be very difficult.
But if you request a url for a directory that does not have a landing page - at least locally you will get a list of files in that directory. If this works it would be a matter of parsing the page to find the file names.

how to use javascript to open a folder and list html file names in that?

I want to list the names of HTML files in a particular folder using JavaScript (in the browser)...
Can anybody help me in this?
Thank You
If you're using Javascript that's running in the browser, there's no way to "open a folder". You have to obtain data about the folder contents through some data structure or by doing something like parsing a server generated folder index in HTML.
If you're using Javascript that's running on a non-browser engine (such as jscript, rhino, etc.) then you have to be more specific in the question as the answer will obviously depend on whether the engine where your script is running provides objects to access the filesystem or not.
This is what you are asking for:
http://www.irt.org/articles/js014/index.htm
Also read on FSO
But yes, if you can't use FSO if ActiveX is disabled on client system.
Javascript can't interact with the OS while running inside a browser, due to security concerns.
It can get a list from the server and display that to the client on the browser, but, to get a directory structure from the client computer to the browser would require some other application reading the directory structure and sending it to the server, and the server sending it to the browser.
Now, if you are using Actionscript it is possible to read the hard drive, and I expect that Silverlight would allow you to do this also, but I don't know.

Categories

Resources