Link to open PDF from folder - html

I have some PDF's sitting in a folder on my computer, is there a way to write a link to open them on to a webpage?
The main idea is when the site goes live the link will be used to download the pdfs from the folder, but obviously at a later stage the folder will be a temp folder on my website.
So at the moment i just want to open the pdfs from a link, and the final goal will be to have the links download them.
Can any one help me?
This is the file path to get to the pdf i want to link to.
C:\Users\Shaun\Documents\FormValue\CS1.pdf
How would i create the link?

If you want to have a link to a PDF, you just have to put the relative path to the file in the href attribute of an a tag. So let's say you had a folder called pdfs, with the file boom.pdf inside it, and folder called site sitting beside it, with the file site.html in it. Then all you'd have to do is put this link in the html file:
Link to a pdf
In most (all?) browsers now a days, that will open the PDF in a new tab. To download it you would right-click it and do the Save Link As thing. Just need to get the path in href right.
UPDATE
If you want to use the full path to the file, you need to prefix it with file://. Then you just put it in the href the same as with a regular link, ending up with something like:
Link to a pdf
This should work with your set up, but if the pdf and the html files are stored near each other, relative URLs are still a good option. A little bit of Google work should show you how to write those.

For each PDF just do what I talk about here.
<object height="950" data="sample-report.pdf" type="application/pdf" width="860">
<p>It appears you don't have a PDF plugin for this browser.
No biggie... you can <a href="sample-report.pdf">click here to
download the PDF file.</a>
</p>
</object>
It works with most browsers and it degrades nicely.

It sounds like youre asking if you can put a link on a web site to a PDF sitting on your computer. You can't. The files have to be either on another web site or on your site's server.

If you are using ASP.NET, you can have the link point to a handler that accepts a query string identifying the file, either by file name or a hash of the file. Then the handler can look in the folder for a file that matches the pattern, read the file as a byte array, and then write those bytes to HttpResponse.

Related

Making a link to an external site and downloading a file simultaneuosly

here's what I have so far but it downloads aff.php and then stops because there is no file in my FTP.
<button>Download</button>
One thing you could do, is remove the first href (href="https://www.abcgameservers.com/aff.php?aff=47") and replace it with onclick="window.open('https://www.abcgameservers.com/aff.php?aff=47')". That way you could have it open the page and download the file.

How is Chrome SingleFile format achieved?

Chrome has an extension called SingleFile. It basically saves a web page in a one file *.htm page that is a clone of the original website. I have seen something like this done with Mozilla MAFF format. The MAFF format saves the file in *.maf, and is you want to see contents (html, css, images etc.) you can change the format to *.zip. Then you can unzip it. With the SingleFile (Chrome) you can’t unzip the file by changing extension. Does anybody know how this is achieved? Is this a known thing that *.htm can offer? Thanks
The MAFF format saves the file in *.maf, and is you want to see
contents (html, css, images etc.) you can change the format to *.zip.
Then you can unzip it.
I'm assuming that you're really asking just how the image files are stored in .htm since html and css can easily be stored as text in htm.
It uses uuencode/uudecode to embed image files in the .htm file. More on that here:
https://en.wikipedia.org/wiki/Uuencoding
This is why changing the extension to .zip won't turn the file into a zip package that you can unzip.
Illustrative side-by-side screenshots of external vs. embedded image.
I found this article may help: http://www.techgainer.com/enable-single-file-mhtml-support-chrome/
On Chrome address bar, type chrome://flags, then hit enter. Now use Ctrl+F (Command+F on Mac) bring search bar and search for mhtml as I did below. Once you find the option, click on Enable link.

HTML PDF not opening

When I reference a .pdf in my webpage, the file doesn't open when I click on the link. I referenced the .pdf with the full path and the file is in the www folder.
When I hover over the link online, I can see that the link is to my .pdf on file but it doesn't open.
What am I doing wrong?
Thanks (HTML newbie)
Edit 1 - reference:
Filename
Edit 2:
I tried the local links extension and it still isn't opening. I also tried <a href="http://www.example.com/myfile.pdf"> and I get a 403 Forbidden error.
Modern browsers block links to file:// URLs from pages that aren't themselves on a file:// URL, and in the same directory tree.
This is a security feature. There are workarounds that you can install locally so it works on one specific computer. See this Mozillazine article.
Sorry - I don't have the rep to comment. But it looks like your ref structure could be wrong.
Try something like:
<a href="http://www.example.com/myfile.pdf">
UPDATE: Hmmm?
Have you tried just:
<a href="myfile.pdf">
Also, I found this which (while not directly relevant) has some discussions and links that may assist: How to set height on PDF file when linked to from HTML?
^^ Ignore that - it really is more related to how the pdf opens.
FURTHER:
I am assuming the pdf file name has no spaces in it. I also assume you have a local pdf viewer.
So I had a look at a random website which had a pdf link as an example. When clicked, it opened the pdf in a new tab. I am on chrome.
You may be able to use that to figure out what is wrong.
Here is the page: http://www.staff.uwa.edu.au/procedures/communications/media/uwanews
Looking at the pdf for the first listed file, this was their link:
Issue-10-December-2014 [PDF File, 2.0 MB]
It looks like path should be enough, but you might want to add the target="_blank" to open in a new tab.
Maybe also see this, which shows that users set how a pdf is opened - perhaps the settings on your end need to be set up: How to open link to pdf file in new tab using html
Anyway, I wish you the best. Post your answer when figure it all out.

permanent link to a single file in a folder that can be replaced and renamed

I tried to think about it but I can't find good answers for my website. Let say I have a folder (online) with one PDF file in it. I want to have a link to it, no problem.
Problem :
Now let say somebody else is going to change that pdf file with another one. The first pdf is deleted and the new pdf file has a different name... so my html link is broken.
Question :
How can i create a link that will open the single pdf file in that folder (no matter if the pdf file is replaced and renamed later) ?
I'm open to any solution even javascript or using google drive or don't know what other method. The best would be a link that works like http://mywebsite.com/folder/*.pdf or something like that.
THANK YOU & good luck to find the answer:)
Use a server-side redirect. This wiki page explains this and gives snippets for PHP, ASP.NET and JSP. Where you redirect to is an outcome of enumerating the PDF files in your folder.
The page that executes this code is the published URL to your PDF. E.g. http://mywebsite.com/folder/pdf.aspx.

In a MediaWiki page, how do I include a link to both a file and the file's description page

In a MediaWiki page, I want to have a link to both the file and the file's description page. I've seen this done before, but I can't find it now... it looked something like
{{file|MyFileName|pdf|This is my PDF file}}
It ended up with the page showing "This is my PDF file" as a direct link, and a little PDF icon next to it that was actually a link to the description page. This worked with pdf, doc, docx, ppt, pptx, and more, I believe. The prefix at the beginning was always "file" and the 2nd option was where you put the file type.
Of course, I just tried this on my MediaWiki 1.19.0 installation and it doesn't work.
It looks like some kind of template transclusion, and either my configuration is wrong or I don't have the template or my MediaWiki version is too old. I have the File template, though because I can get half of it working like this:
[[:File:MyFileName.pdf|This is my PDF file]]
I even remember seeing a page describing these two formats as the "old" and "new" ways of linking to files, but I can't find that page now either.
To elaborate, the template would probably have a structure like this:
template:file
[[Media:{{{1|}}}.{{{2|}}}|{{{3|}}}]]<!--
-->[[File:{{{2|}}} icon.png|link=File:{{{1|}}}.{{{2|}}}]]
The go ahead and load an icon image for each file type you plan on using. (If the image isn't icon-sized, you'll want to add a width modifier in there as well.) With this template, {{file|MyFileName|pdf|This is my PDF file}} should generate exactly the output you describe: a direct link to MyFileName.pdf called "This is my PDF file", followed by an embedded image File:Pdf icon.png that is also a link to the description page for MyFileName.pdf.
You can create a simple version of such template like this:
[[Media:{{{1}}}.{{{2}}}|{{{3}}}]] [[:File:{{{1}}}.{{{2}}}|(description)]]
The Media namespace is used to directly link to the file; : specifies that you want to link to the description page and not show the file.
If you want to have an icon for each file type, you would need to {{#switch}} on the file types.