Search code examples
htmlbrowsernetwork-drive

launch network location from browser


I am working on a webpage to provide download link to a searched file from the input form from user thru webpage.

I can use the html <a> tag as in <a href="file://ip/path/filename> link</a> But when the file is in a network require login, i cannot do it.

Following is not working. i had tried <a href="file://username:password@ip/path/filename>link</a> and <a href="file://ip/path/filename" username="username" password="password">link</a>

the file i need to link is locate at different network location based on user input to the browser form. then the backend python will search the file location.

can anybody give me a help ?

thank you.


Solution

  • Unfortunately, you are trying to do something which protocols and browsers do not support.

    The username:password in URLs are designed to be consumed by a Web server. When you insert them in file URIs, there is nothing that will consume them; there's no HTTP server on the other end. Hence, the browser actually strips those before it extracts the file path from the request, and passes the file request to the OS.

    You need to either make sure that the end-users are preauthenticated to all the network shares you are going to access, or avoid file URIs and set rudimentary web servers at your file targets.