Get contents of local folder in javascript (or ASP.NET VB)

Is it possible for a web page to open a dialog box for an open folder, asking the user to select a folder, and then display the contents of this folder in the list (or something else) on the web page. He will not write files, but only read them. The web page is hosted remotely.

Jonathan

+4
source share
6 answers

In a word ... No.

Requiring an ActiveX plug-in for your application is an invitation to complete failure. If you are not writing an application for specific purposes on an intranet where you control the configuration of a client, this is just a terrible idea.

There are strict limits on what a web application can do, and this is one of them. What are you trying to achieve? Perhaps there is a way to do this using the standard file upload dialog box? Or WebDAV?

+5
source

I wrote this small piece of code that shows a list of files with the name of the folder. It is written using VBScript, so it will only work on IE and FireFox (and possibly only on windows). But worth a look

<HTML> <HEAD> <SCRIPT LANGUAGE='VBSCRIPT'> Sub showfiles() On Error Resume Next Dim fso, folder, files, sFolder, path Set fso = CreateObject("Scripting.FileSystemObject") sFolder = Document.getElementById("fdr").value Set folder = fso.GetFolder(sFolder) Set files = folder.Files For each folderIdx In files mydiv.innerhtml=mydiv.innerhtml & "<BR/> " & folderIdx.Name Next end sub </SCRIPT> </HEAD> <BODY> <INPUT id="fdr" TYPE="TEXT" VALUE="C:\" /> <INPUT TYPE="BUTTON" ONCLICK="showfiles()" value="show files" /> <DIV id="mydiv"></DIV> </BODY> </HTML> 
+1
source

You can use the Signed Java Applet, this is a fairly common solution. It works in browsers and platforms. All users will need to accept your certificate once and set the java runtime.

Alternatively, you can write a browser plugin.

+1
source

Edited : - See this . Maybe a workaround.

0
source

It will make you (or your usesr) jump over a thousand hoops, but you can use the ActiveX file system object to accomplish what you want ...

http://msdn.microsoft.com/en-us/library/bkx696eh%28VS.85%29.aspx

edit - added "maybe"

0
source

It is not possible to do this using JavaScript, because it does not have the ability to work with the operating system.

however, this is a way to do this using VBScript (ASP.NET), but IE issues a security warning to the user before allowing code execution only if their security level is less than Medium-Low.

If you are trying to access local files over the Internet, it is best (except to detect vulnerabilities and gain access this way, i.e. a bad way) using Java or Flash.

If you still need code (for ASP / VBscript):

Dim FileSystem
Set FileSystem = GetObject("Scripting.FileSystemObject")
If Err.Number <> 0 Then
MsgBox("Error setting FileSystem object; check WSH version.")
WScript.Quit(0)
End If

Dim Folder
Set Folder = FileSystem.GetFolder("folder_name")
If Err.Number <> 0 Then
MsgBox("Error getting folder.")
WScript.Quit(1)
End If

-Carlos Nunez

0
source

Source: https://habr.com/ru/post/1304684/


All Articles