Reputation: 585
I am trying to use my html\ javascript to access a PDF file.
I have checked to see if the file exists which it dose however its still returning an error alert stating that the file is not found could someone elaborate on this form me?
<p>Zoek voor project Nr:
<input type="text" name="prog_site" id="prog_site" value="" />
<a href="#"
onclick="this.href = ('file://j:/' + document.getElementById('prog_site').value + '/Tekeningen/TekenwerkDeMar/Definietief/' + document.getElementById('prog_site').value + '.pdf' )"
target="_blank">Get</a>
Upvotes: 0
Views: 173
Reputation: 29932
Most browsers have restrictions on opening local files from a website. If this were allowed, anybody could read your personal files from any website you are visiting.
A) You can upload the file to some webhost to access it via the http:
instead of file:
schema.
or
B) You can let the user select the file via <input type="file" />
and access it via the DOM File API.
Upvotes: 1
Reputation: 10896
try something like this
CHANGE THIS
file://j:/
TO
http://localhost // server [use your server url]
Upvotes: 0
Reputation: 22711
You need use domain
path instead of file path
this.href = ('http://example.com/' + document.getElementById('prog_site').value + '/Tekeningen/TekenwerkDeMar/Definietief/' + document.getElementById('prog_site').value + '.pdf');
or even instead for in local instance use localhost
or ipadress with port if configured.
Upvotes: 1