Reputation: 13
I'm trying to get the absolute path to use as a static reference
<input type="file" onClick="getFilePath">
function getFilePath(e)
{
console.log( e.target.files[0] );
}
but I'm getting only the name of the file..
for example if I need to open an image locally I need to provide the url
new ImageLayer({
source: new Static({
url: 'https://foo.bar.com/lorem/image.png',//Local path goes here
projection: projection,
imageExtent: extent
})
})
Upvotes: 0
Views: 280
Reputation: 33
If it's the path of a file, it can be done easily with node.js like so...
const path = require('path')
path.dirname('whatSoEver')
Upvotes: 0
Reputation: 1530
You can't, you have to serve the file first.
Either you do it by creating a persistent reference string with a unique URL that temporarily references to the in-memory blob object that lives in the Blob URL Store by using URL.createObjectURL()
Or going to your local directory and serve it using http-serve then use the link as a path
localhost:8080/foo.txt
Upvotes: 1