Link to home
Start Free TrialLog in
Avatar of mistaeverly
mistaeverlyFlag for United States of America

asked on

File Listing of Local Drive

I have posted this question in the javascript forum, but I am open to any solutions that work, regardless of language.  My problem is as follows:

I have a web-based application written in PHP that stores archive information about stored CDs and DVDs on a MySQL database.  Basic information like job name, description, etc is stored.  It is also possible to upload a log file (created using a 'dir *.* /s > logfile.log' from the dos prompt) which will then be associated with that particular piece of media.  In reality, I don't even store the log files, but I have a PHP script that parses them to find filename, size, etc, then stores them in my MySQL database to speed up the searching process.  This enables, for example, the users to search for all media that has file 'fileName1.txt'.

My problem is that I would like to simplify the process of uploading the log file and give the user the option to simply choose the drive letter that their CD/DVD is in and have a script that will create a file listing of that CD and somehow interact with the server to enable me to insert these new files into my MySQL database.

I'm having some serious problems with this (I have no experience with file operations on a local drive) and I'm beginning to wonder if this is even possible, but I think it must be.  Any help would be very much appreciated.

Thank you for your time.

Chad
Avatar of RanjeetRain
RanjeetRain

Where will your page be loaded from?

     If it will be loaded from a Webserver, you can not do it. It will be a threat to the system security.

     If you want to do it from a page loaded from the local system, you can do it.


Avatar of mistaeverly

ASKER

It will be loaded from the webserver.  However, I was thinking of some kind of workaround that would require the users to download a html (or perhaps even a java applet) which could then be run client-side.  This could then find the directory listing and call a PHP page server-side using GET variables.  This PHP page could then take these GET variables and insert them into the database.  Again, I don't know if this is possible... thus the question, but it seems like this general idea might work.  And I stress "might".

As far as security goes for my server, only company machines connected through our VPN have access to these pages, so external security threats are negligible.

Thanks again.

Chad
You can do this sort of thing with a signed applet.  It basically goes like this :

1. A user goes to some page on your website.   This page contains the signed applet.   The signed applet needs to be configured so that it requests read access to the local filesystem.

2. The configured JRE plugin for your browser will ask the user if they trust you (the entity specified by the certificate associated with the signed applet).   If they press "yes", then your signed applet will have filesystem permissions.

From that point, you can use the signed applet to communicate back to the serverside...

For more information on signed applets, see :


http://www-personal.umich.edu/~lsiden/tutorials/signed-applet/signed-applet.html





Positive outlook. You can have many workable solution.

1.  You can develop an ActiveX control to perform this task. Create the ActiveX control and sign it. Now create your HTML pages and embed an instance of your control in it. When the page loads in the browser, it will download the control from the place mentioned if needed. The first time around the control will install itself. Since its your VPN, you may instruct your users to say "yes" to security dialog. Once your control is loaded, it will have "full access" to the client PC. Play with it any way you like. (Most of the dialers on xxx.com and xxx.net use the same method).

2.  You may do the same with Java Applets. Even for Java Applets the methods remains the same, only the implementation differs. Moreover, Java Applets will work on "all" platforms, whereas ActiveX solution will work only on Windows.


Anything, I need to explain more?
Your html pages can use javascript and the FileSystem object.  The FileSystem object is an UNSIGNED activeX that allows web pages to access the client's file system.  Normally unsigned activeX's cannot be accessed in IE, but you can have your users change the settings (be carefull though, you do NOT want to make corporate IT security mad at you)

To get an Instance of the object add the following to your function:
  var Fo = new ActiveXObject("Scripting.FileSystemObject");

See the following links for example:
https://www.experts-exchange.com/questions/20837002/Write-to-txt-file-using-JavaScript.html
So there seem to be many possible solutions.  I would hesitate to use MogalManic's solution (unsigned ActiveX) because of the security risks as well as the extra step of forcing all users to change their IE settings.  The solution need only work on Windows, so certainly the Java applet and ActiveX solutions would both work.  To be quite honest, I have zero experience in either Java or ActiveX, so I don't know which route I should take.  Please advise.

Again, I wish to thank all of you for your help.  I can certainly split up the solution points and even add some if necessary since there are so many of you to respond.
Go for Java Applet. That's safest and *truely* cross platform.

ActiveX is NOT cross platform. Sorry, If i earlier sounded like that.
I've been looking around, and I literally have no idea where to start.  Should I repost in a Java forum, or are ya'll able to help me?
Here's an article which should help you :

   http://www.developer.com/java/data/article.php/3303561

I've been trying to figure this stuff out but it seems that even the simple examples are quite difficult to follow for a Java newbie like myself.  I don't particularly have time to learn Java thoroughly in order to solve this problem.  I've downloaded NetBeans IDE 3.6 from Sun's website and have been messing around with the applet stuff, but I'm having a heck of a time.  Nothing makes you feel quite so ignorant as starting over with a new language.  If anyone could suggest a quick fix that wouldn't require me to master a difficult language, I'd be most appreciative as time is an issue.
Thanks.

Chad
Chad,

I wish I could do the code for you, but its not easy. Unless someone has ready code, no one can afford to write it afresh. My advice to you would be, try your hands on it and then post your quesries in form of small small questions in the specific area. For instance, if you decide to use Java Applets, for you the best thing would be to turn to Java experts.

Good luck!
ASKER CERTIFIED SOLUTION
Avatar of sgalzin
sgalzin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Wow, Stephane, thank you very much.  Initially I got an error instanciating the ActiveX object, but after changing a security setting to "Prompt" instead of "Disabled", it works like a charm.  Now it's just a matter of adapting it a little to suit my purposed.  But you've certainly done most of the heavy lifting.

My thanks to all of you who helped me out.  It's been a pleasure.

Chad