Avian Gamers Network http://www.avian-gamers.net/forums/ |
|
HTML interface for USB storage device http://www.avian-gamers.net/forums/viewtopic.php?f=1&t=12169 |
Page 1 of 1 |
Author: | Cyrus Rex [ Mon Jul 12, 2004 8:56 pm ] |
Post subject: | HTML interface for USB storage device |
I am wanting to create a HTML interface for my USB storage device. Is there any code that would scan a folder and list each file in the folder as a link to the file? |
Author: | iJasonT [ Mon Jul 12, 2004 9:37 pm ] |
Post subject: | |
this is pretty straight forward code but I am not sure if HTML can do it. You would need a dynamic language like PHP or ASP or even JSP. The main reason is opening a folder is one thing but then looping a command and writing the file to a text link is a whole other thing. the fopen and fclose command is a nice place to start some research on the topic. Just do a google on php+fopen |
Author: | iJasonT [ Mon Jul 12, 2004 9:40 pm ] |
Post subject: | |
I should also note that the fopen command only works with the folder structure accessable via the HTML/PHP language so it would need to be within the Web folder. If you want to look for folder on your standard HD then you are looking for a C or C+ or even PERL script |
Author: | Cyrus Rex [ Mon Jul 12, 2004 10:13 pm ] |
Post subject: | |
What I want to do is have a web interface to organize my storage devices contents. I am wanting the file listing to be dynamic so that I do not have to do the html every time I add a new file. -If I want to look at my resume, I go to the resume page and from there all the versions of my resume are listed. (I would have a resume folder holding all resumes) -If I want to look at all my files for my CM 4200 class I go to that classes page, and from there all the files are listed that are in my CM 4200 folder. Most things that I found so far ask for asp or something like that. Everythign seems to be server oriented. I ran the following bit of code, but upon viewing it, I get a window that says I must allow the activeX Object to run... which is the error message on line 15 of the code. Code: <html>
<head> <script type="text/javascript"> <!-- var fsObj = null; var foldedToList = 'C:\\Windows\\System32'; function listFiles() { try { fsObj = new ActiveXObject('Scripting.FileSystemObject'); } catch (err) { } if (!fsObj) { alert('You must allow the ActiveX object to run!'); } else { if (!fsObj.FolderExists(foldedToList)) { alert('The folder:\n\n' + foldedToList + '\n\ndoes not exist!'); } else { // at this stage, we can list all files var folderObj = fsObj.GetFolder(foldedToList); var filesObj = new Enumerator(folderObj.files); filesStr = ''; while (!filesObj.atEnd()) { var tempFile = filesObj.item(); filesStr += '<a href="' + tempFile.Path + '">' + tempFile.Name + '</a><br>'; filesObj.moveNext(); } document.getElementById('fileList').innerHTML = filesStr; } } } //--> </script> </head> <body onload="listFiles();"> <div id="fileList"></div> </body> </html> By no means am I bound to this code. I will use anything that works on my PC and the PCs at school. |
Author: | Cyrus Rex [ Mon Jul 12, 2004 10:22 pm ] |
Post subject: | |
Ok dumb me... it is working now, but I need to refine it to the folders I need it to look in. ** I wonder if this ActiveX stuff will be blocked at school? |
Author: | iJasonT [ Mon Jul 12, 2004 10:35 pm ] |
Post subject: | |
nice find. The good thing about Java is that is will run outside the server environment and look into files on your drive. I know almost nothing about Java but I may poke around the script to see how it works and if I can tweak it a bit. |
Author: | Cyrus Rex [ Mon Jul 12, 2004 11:25 pm ] |
Post subject: | |
How can I make it look in the right place no matter what PC the USB Drive is plugged into???? The code is directed to the folder with this line: Code: var foldedToList = 'C:\\Windows\\System32'; For my PC, the removable USB drive is F:\ so as long as the code has the correct path it can display the folder contents. For example, right now I am testing it by looking at one of my web graphics folders. I am using the following which works fine on my PC: Code: var foldedToList = 'F:\\GUI\\images\\MainButons'; However on other PCs it may be a different drive letter. On my wife's it is E:\. Thus on her PC the code can't find the folder F:\\GUI\\images\\MainButons. In html, when directing to images, the full path is not needed. You can just start with the folder you are in and leave out the preceding stuff such as Code: <img src="images/MainButons/MButton_Main_on.jpg" ....
Is there any way I can make my javascript work with out giving it the full path? Is there a way to do it like we do the image paths? If I did not have to give the full path, I may be able to get around the changing drive letter problem. |
Author: | iJasonT [ Tue Jul 13, 2004 12:45 am ] |
Post subject: | |
with PHP this is a very easy thing to do, all I would do is make a drop down list that has A: B: C: D: E: F: G: H: and you could choose which to pass. Then it would use the Variable (Var) and substitue $drive for the chosen letter. But in Java I would have no way of knowing how to pass a Var, although I know it is possible. One quick solution. I assume you have this HTML file on your flash card device? If so just make 4 or 5 files labels filesD filesE filesF etc and edit each file so that the drive relates to the fileX. Pretty clunky but effective for a short term fix. Again, I just don't know Java so I am no help. |
Author: | iJasonT [ Tue Jul 13, 2004 12:48 am ] |
Post subject: | |
BTW how did you get around the Active X error message? |
Author: | Cyrus Rex [ Tue Jul 13, 2004 1:11 am ] |
Post subject: | |
I was getting the error when I was previewing the file in my html editor.... but when I view the file with my real browser it works fine. On pages with the script, I get an activeX warning. I choose OK, then I get another warning window from my antiVirus stopping the script, but I choose to let it run... and everything works perfectly. Now I have the antivirus warning set to let this particular script pass without the warning. Until I get the dynamic drive path problem fixed, I will be populating the drive will all my school stuff, and building the buttons for the school section of the site. Basically filling the thing up with all the files I know I will need, which are of the type that would be hard coded. So far it is moving along fast… but I am holding off on the hover script until tomorrow when I am not so tired. Obbo will be getting up soon. I am hoping that he may know how to get around this dynamic drive path problem. |
Author: | iJasonT [ Tue Jul 13, 2004 1:19 am ] |
Post subject: | |
ahh yes I opened it in IE just fine. I couldn't get it to work while viewing through Mozilla, my default browser. |
Page 1 of 1 | All times are UTC - 5 hours [ DST ] |
Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |