Using the MS Edge browser on Windows 11 … I have a directory with three PDF files, two of which are inside a zip file:
- file1.pdf
- myfile.zip/file2.pdf
- myfile.zip/file3.pdf
I want to access these from a static HTML page. Something like …
<a href="file1.pdf" target="_new1">file1</a>
<a href="myfile.zipfile2.pdf" target="_new2">file2</a>
<a href="myfile.zipfile3.pdf" target="_new3">file3</a>
Obviously, while the first link works, the other two don’t. Is there a way to do this?
(Note: This isn’t my regular skill area. So, ‘semi-newbie’ answers, please.)
UPDATE: I did simplify the scenario to keep the question simple. Actually, there are over 1000 PDFs in a directory tree (some in ZIPS, some not). These are all subject to being updated by an external process on an ad-hoc basis. If not for that then, yes, simply unzipping everything would be the easiest approach. Maybe the best solution is to routinely scan the directories for changed ZIPs and unzip any updated ones … but I wanted to see if there was a better way: either access directly (if possible) or some sort of JIT unzip when a link is clicked.
2
Answers
A ZIP file is not a directory, but is a file itself.
It is highly recommended that you unzip the ZIP file to a folder. For example, you may extract the
myfile.zip
to a directorymyfile
on your server then use codes like:And if you JUST won’t do that, you may try using a Javascript library to unzip files. I searched the Internet and found this one:
JSZIP
You may try reading the documentation and add a Javascript to your HTML to extract the ZIP file you can get.
Edge is generally restricted in what it can do with secured files thus you cannot address a zips contents directly but you may address a zip folder.
However that folder if its a zip will be treated as a download and then the cached file will be opened. BUT again be restricted in what is allowed. For example the user may copy and paste to another folder (unzipped of course).
what can you do to view a file in a zip is thus constrained to what you may run in a shell script (i.e. possible from a HTA web page)
to view a pdf from a zip you need vbsjsps1cmdbatscripts along the lines of