Accessing a folder to list/play clips one by one - javascript

I just want to know if there is an object to access a folder path which includes list of clips in javascript.
Which object I should use to list clips in a folder? Actually I can't use all objects, only provided for Ecmascript.

JavaScript/Ecmascript cannot see the local filesystem. If it could then we'd have web pages sniffing all of our files without our consent.

JavaScript doesn't get to see the user's file system. That'd be a huge security problem for everyone everywhere. If you're referring to the server's file system then you probably already have a better language like php that can list the directory contents and dynamically generate the JS before it is sent to the browser.

Related

Javascript URI/Origin Override

I have a very specific challenge where a self contained website and assets are stored in a location that is not a web server and cannot be a web server.
I need to be able to provide staff a stand alone index.html file that they can run from their local computer which will reference the online location as a sort of external storage repository.
The website has a lot of assets and javascript... in many cases the javascript calls to assets using local paths such as images/image_file.png
Without manually updating all the asset paths within the website code, modifying hosts file... using iframe... is there a way with javascript alone to add prefix to all paths that come after in the document?
Almost like defining or setting origin which I don't believe is possible.
I had thought to read the code in with a parser and try and regex replace but was hoping for a simpler solution.
Thanks in advance for your consideration.

How can i display the merged contents of local files from a js+html page running locally

I have a bunch of files(not necessarily text files) on disk. I need to display the merged contents of all these files in a html page opened locally on Load. Is this possible without using Active-X? My objective is to create a summary of a set of files and at the same time to keep the summary file small. Infact most of the files whose data I need to summarize are html files.
If this is possible can I also choose only certain sections of text in each file to be part of the summary?
It would be great if the solution would have a wide browser support.
Any example would help a lot.
Thanks.
Open the files in iframes then pull the source of each and process it. Since it is coming from your own machine, there should not be any cross-domain problem.
Javascript does not have access to the clients file system, therefore I do not believe this is possible. See this post: Local file access with javascript

work on the files in a directory using html javascript

Trying to see if this is possible -
1.) User logs into our site
2.) Points to a directory
3.) The javascript code reads contents of the directory, shows thumbnails for any jpeg/gif in those directories. This all without uploading all the photos to the server. Kind of a semi desktop app.
Point 3 is something I have never done, is this possible for an online application to do ?
You can't do this...yet (unless you're using a prerelease of Chrome 9). There are some APIs coming down the pike that will make this possible in browsers that support them; there's a description of using them in this article.
But right now, no. To do this, you'll need to use a technology that allows local file access, such as a signed Java applet (normal unsigned ones obviously can't do this) or, on a severely limited number of platforms and browsers, an ActiveX control.
Update: Sorry, the new JavaScript APIs I mentioned above don't give you (user-granted) access to any old directory on their system. They do give you access to the file system, but it's a sandboxed file system. So you'd have to have the users move the files into the sandbox (which you could do via the File API and with drag-and-drop, keeping it an entirely client-side thing, no uploading required). But that isn't quite what you described.
No; this is not possible.
Javascript cannot directly interact with the user's local filesystem
No, it is not possible to access any of the clients files using JavaScript as that would be a security risk.

Foreach file in directory jQuery

How can I do a foreach(File file in Directory) kind of thing in jQuery.
Thank you!
Javascript does not have access to the local file system for obvious security reasons. This is not possible.
Unless you are trying to loop through files on your server, in which case you wouldn't want to use jQuery anyway but something like ASP.NET or PHP or whatever framework you are using.
$('selector').each(function(idx, elm){
//some code
});
Will allow you to iterate over a list, applying the same function to each. However, accessing the filesystem is not possible.
It is not possible with javascript/jquery to read contents of a directory for security reasons. Imagine you are trying to read the file system of client machine. You can use FSO (File System Object) but that works only in IE. You can use server-side languages such as PHP, ASP.Net for accessing the file system.
If you meant a loop with each, consider the each method of though. Example:
$('selector').each(function(){
// your code.....
});
If the files are on the client you can't access them for security reasons.
If the files are on the server and you want process the list sever-side you wouldn't use JQuery as it's for client-side scripting.
If the files are on the server and you want to process the list client-side, you could generate the list in the server code and send it down as xml, json, etc.
If the files are on somebody else's server your only options is to recursivly follow links on their site, which is not really something you'd want to be doing with Javascript from a client's browser.

How can I iterate through files in Javascript

Is it possible to iterate through a collection of files in Javascript? I am writing a jQuery plugin that takes either an array of images or, I was hoping, a directory containing a list of images. E.g. either:
['image1.jpg','image2.jpg','image3.jpg']
or 'http://somedomain.com/images/'
I would then like to be able to iterate through the above domain and take the file name from each of the files in the folder.
I have read about the FileSystemObject but this will only be available in IE, is there an equivalent that can be used in all browsers?
You should use server side language to provide array of images in JSON or similar. There is no way Javascript can access local files. That would be serious security issue.
If the directory is on the same domain, and your webserver is setup to show directory indexes, then you could use javascript to request the url and load it into the dom for data extraction. This is brittle, and doesn't sound like it would make for a good plugin, much less good for anything but a one off task. But, you could do it.
The other suggestions of having serverside script output json or xml would be an improvement.
You can't.
You have to get the list from your server through JSON or XML. Because of this, you can't do this in any way with javascript on servers you have no control over. Also, access to client side files is actively avoided for security reasons.
You would need to create a web service to fetch the list of files. You can't use ajax to directly fetch the directory listing because ajax calls are restricted to the domain.

Categories