Hi everyone
I'm more than a little stuck and would appreciate a hint. I'm struggling to read files in a folder and then pass the variable to the following:

</body>

<OBJECT ID="MediaPlayer" width=320 height=310 classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" type="application/x-oleobject">
<PARAM NAME="FileName" VALUE="video/RC Radio Controlled Model Airplane [from].wmv">
<PARAM NAME="AutoStart" Value="false">
<PARAM NAME="ShowControls" VALUE="true">
<PARAM NAME="ShowStatusBar" VALUE="false">
<PARAM NAME="Enabled" VALUE="true">
</OBJECT>

<FORM name="MediaForm">
<SELECT NAME="VidChange" onChange="{document.MediaPlayer.FileName = document.MediaForm.VidChange.options[document.MediaForm.VidChange.selectedIndex].value}">
<OPTION VALUE="video/RC Radio Controlled Model Airplane [from].wmv">RC radio plane flick
<OPTION VALUE="C:\Desktop special\leftmenu\video\intro.wmv">Intro
</SELECT>
Loop:
<INPUT TYPE="checkbox" NAME="VidRepeat" onClick="{if ( document.forms.MediaForm.VidRepeat.checked == true){document.MediaPlayer.PlayCount = 999}else {document.MediaPlayer.PlayCount = 1 }}">
</FORM>
</body>

I just learning scripting languages...really it's all new to me.
Thanks very much

Prophetboy

Dani AI

Generated

Quick summary and practical options (updated):

Browsers intentionally prevent plain client-side JavaScript from enumerating arbitrary folders on the user’s disk. As pointed out, server-side code or a trusted native app is required for full directory access; is right that desktop languages (VB/Perl) can do it too. For a workable solution today there are three common approaches depending on whether this is only for your machine or meant to be served to others.

If you can run a local server (recommended for testing and publishing)

  • Use a tiny server-side script (PHP, Node, etc.) to read the folder and emit the <select> options. Example PHP snippet (place next to your video folder and load the page via HTTP):
    <?php
    $dir = 'video';
    foreach (array_diff(scandir($dir), ['.','..']) as $f) {
    $ext = strtolower(pathinfo($f, PATHINFO_EXTENSION));
    if (in_array($ext, ['mp4','webm','ogv','wmv'])) {
      echo '<option value="'.htmlspecialchars("$dir/$f").'">'.htmlspecialchars($f).'</option>';
    }
    }
    ?>

    Run a local server (for quick testing python -m http.server or use PHP built-in server) so links resolve with HTTP URLs instead of C:\ paths.

If it must be purely client-side on your desktop

  • Let the user pick the folder. Modern options: an <input type="file" webkitdirectory> to get a FileList, or the File System Access API (showDirectoryPicker()) to iterate files. These let JavaScript read filenames and create blob URLs for playback. See the browser docs: input file and File System Access API.

Compatibility and format notes

  • The old WMP ActiveX approach only works in Internet Explorer. Prefer the HTML5 video element (video) and convert WMV to MP4/WebM for broad browser support.

Recommended Answers

All 6 Replies

You can't do this with a HTML scripting language.

If you use a server side language - something like JSP, ASP, PHP etc, then you can scan the server directories and populate a list in the webpage.

Also, remember to use web URL paths and not filesystem paths:

C:\Desktop special\leftmenu\video\intro.wmv

These will work when you are testing on your computer at home, but not when you publish to the web.

Cheers.

Thanks for replying but I think I stated my intentions poorly. What I want to do is scan a folder for specific files (on my own computer) and then put them in a list box as a selection. I'm putting this page on my desktop as a web page. I'm trying to use a scripting language such as JavaScript to read the files from a selection.

I tried to use this to read a fold but I couldn't get it to work for me.

The next is a copy of the original project I found and was endeavoring to change.

you will see on the left menu there are selections. I want to be able to select one and have a media play show a list box show the videos in the folder.

Right now I live in China and can't run to the store to buy English books and I've looked on the net but I'm not having a lot of luck finding the material.

can you help

Chad

Scripting languages are generally prohibited from searching a computer outside the web page environment for security reasons

I have written such a function in Visual Basic.

It is possible to run applications on the client machine, but this is usually not appreciated by the user and involves signing trusted code.

A better alternative may be to request the client user to browse their computer for a file they want to load.

Unless this is only meant to be for your use.

Use VB or Perl to do things on your own computer.

hi...
I too had the same problem.But you message worked good..
Let me explain about the TWAIN and OCR.

You can't do this with a HTML scripting language.

If you use a server side language - something like JSP, ASP, PHP etc, then you can scan the server directories and populate a list in the webpage.

Also, remember to use web URL paths and not filesystem paths:

These will work when you are testing on your computer at home, but not when you publish to the web.

Cheers.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.