Reputation: 484
I own a local PHP point of Sale, using wampp as my web-server (Win7). What I'm looking for is to find a way to open the Flash Drive E as we normally do by visiting My Computer - > USB Flash E: ... but using JavaScript.
I have found this code, which works perfectly as needed... But this only works on IE, I'm using Google Chrome as my POS browser but what Chrome does... Opens up a blank window!
Here is the code:
<script>
function CallMe()
{
window.open("file://PCNAME/E$");
}
</script>
<html>
<input type="button" onClick="CallMe()" value="Open USB" />
</html>
Is there an alternative way to open USB Drive E? Maybe by using PHP?
Upvotes: 7
Views: 75918
Reputation: 39
Open file explorer in JS with :
showOpenFilePicker()
function.
You can pass the arguments "desktop"
, "documents"
, "downloads"
, "music"
, "pictures"
, or "videos"
Handle the select fiel with :
showOpenFilePicker("documents").then((fileHandle) => {
console.log(fileHandle);
});
FileSystemFileHandler is returned
Full doc : here
EDIT : WILL NOT WORK ON FIREFOX
Upvotes: 2
Reputation: 65499
You could allow the user to navigate their filesystem from the browser using:
<input type="file" />
You can't specify a default location nor can the browser open it automatically, however.
Upvotes: 11