Displaying local htm file in iframe? - html

I am saving some emails on my local machine using MailBee.NET Objects in htm format. A separate folder is created for each email using email messageID on server for example
D:\Emails\GmailId1380ec660e0e656a\doc.htm
is an email downloaded from gmail. I am saving also the above mentioned path in database so I can use it later. Now I am trying to display this htm file in an iframe but it is not working. A user clicks on email which takes him to the read_email page on which I am trying to assign the path mentioned above to an iframe but the iframe remains blank.
emailMessage.Attributes.Add("src",commandReader["email_message_path"].ToString());
emailMessage is the name of iframe and commandReader is normal SqlDataReader which I am using to read the path of the file mentioned above and then assigning that path to src attribute of iframe, I have placed this code in page_load event.
But as I said Iframe remains blank. Please help me out.
Thanks.

Local files are referenced with the file URI scheme. If your email message path is only D:\Emails\... then you'll have to prepend it with file:// :
file://D:\Emails\...
Note that most browser will prevent you from including a local file from a remote website !.

Have you tried putting file:/// before the path to the file?
Like file:///D:\Emails\GmailId1380ec660e0e656a\doc.htm

Related

Why won't my images show in my HTML file?

Is there something wrong with my syntax? I have an images folder located in the same folder as the html file. Images from URLs work fine.
<img src="images/ai_1.png" width="500" height="300"/>
Images folder
Given that the directory is named templates…
You have some server-side (or build-time) code which takes a URL and somehow translates that into an instruction to generate an HTML document from that template and other stuff (probably includes and some page specific data).
The relative URL you have in the src attribute is computed from the URL of the generated HTML document.
The browser asks for that URL and the server can't find a suitable response for it.
The image files aren't templates so shouldn't be in the templates.
This kind of system typically has a specific directory to store static files in. The images should be in there.
You then need to specify a URL which is mapped onto that static directory by the server code.

Can't access local file via local webpage hyperlink

I'm having some trouble linking to a file on the network via a local webpage. I've written a simple html page with a hyperlink:
View File
Now what happens is when I click the link, I get an error message that windows cannot find the file specified. The file does exist but the link to the file that is displayed by the error message is not right.
I have:
h:\myfiles\dir#1\file1.s
Error Message:
h:\myfiles\dir#1/file1.s - All slashes after '#' are flipped.
I tried it again, but this time I removed the '#' from the directory name and fixed the hyperlink accordingly as well (View File). When I did it this way it works. I guess what I'm asking is that is there a workaround for links to directory files that have a '#' in the URL?
I know '#' is a special character and is used for anchor bookmarks, but how do I get around this. I don't want to remove the '#' for all the directory names that I have. How do I link to a file in a directory that has a '#' in it's name?
Thank you!
The # sign can be encoded as "%23". You might remember "%20" appearing anytime you tried entering a URL with a space in it (before browsers started switching to search anytime it didn't fit URL patterns)

Usage of audio and video tag in Nitrogen

Still working on my personal web server, I was trying to use the html5 audio and video tags within Nitrogen.
As there is no #audio nor #video records, I decided to insert html text directly in the page generated by nitrogen, the result looks like this:
<audio controls preload="metadata"><source src="../../My Music/subdir/song.ogg" type="audio/ogg" /source>audio tags not supported</audio>
In my understanding this should work because the audio tag is supposed to be interpreted directly by the client browser, and there is not any nitrogen id or event observer in the code.
But when I browse this code from Firefox, I briefly see the control opening, and then the audio element simply disappears.
If I copy paste the whole code generated by nitrogen (display html source page, copy and paste in a file located at the origin of the nitrogen project) and open it with the browser, it works fine. The relative path is correct, assuming that the search stats in nitrogen project. I have tried absolute path also, without success.
I don't know
if it builds a file name of the form ".._.._My music_subdir_song.ogg" like nitrogen does for url analysis,
or if it uses another directory to start the path,
or if it simply doesn't work the way I am thinking.
...
Edit: some complementary information:
I have done the following changes:
create one directory including some ogg files in the site/static directory + move a static test.html file in the site/static. If I open directly test.html -> ok. if I redirect from my web site -> Not ok.
same test with a copy of the directory at the Nitrogen application root and access from my web site -> not ok
As the information on the web page is ambiguous, I modified test.html to access to a file that does not exist on my PC -> same behavior.
I think I'll use the debugger to understand how the request is managed, to be continued...
Edit 2:
using the debugger I can verify that the wf_core:run_catched() is called several times. The fist call is when it process the event in my page that redirect to the static file.
The second time to process the static html file itself.
A third time to process finish_static_request() with a Path equal to my_music/song.ogg, and then I get lost in the processing of the answer. Another wf_core:run_catched() was called in parallel, but I didn't follow it...
I have been able to verify that the file can be accessed: I have added several audio tag in the html files, and I was able to "download" the existing files using the DownloadHelper Firefox plugin.
My understanding now is that the path is correct (at least when I place the files in a subdirectory of site/static), the server is able to retrieve the files and send them, the browser recognize the audio and video tags, but the link between the embedded audio/video reader and the files is lost, although I have added a type definition inside the audio tag.
Any idea to continue?
Edit 3:
Finally I got it. As Chops suggest it I had to go in the inets server configuration, not to define the path, but to define the type association. I have added the following definitions in etc/inets_httpd.erlenv, and it works.
{mime_types, [
{"css", "text/css"},
...
{"ogg","audio/ogg"},
{"webm","video/webm"}
]}
:o)
Based on the contents of the url attribute ("../../My Music/subdir/song.ogg"), the problem, when it's served from Nitrogen is that the request (Assuming you're using the default 127.0.0.1:8000) for the audio will be to the url "http://127.0.0.1:8000/My Music/subdir/song.ogg"
What you want to to do, if you're using the standard Nitrogen installation, is to put the song files you want into the site/static directory, perhaps in "songs" subdirectory.
Then change the url attribute to be "/songs/mysong.ogg" (or whatever path within site/static you used).
Note: Dependinding on your server choice (Webmachine, for example), you may need to tinker with the server's specific config file to tell it to handle the new directory for static paths, for help, check the configuration docs on the Nitrogen site.
Beyond that, there's nothing special about outputting raw HTML in Nitrogen. It is my understanding that the problem here is really just related to the paths of the requests being sent to the server.

Link to open PDF from folder

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.

Opening a Local PDF file in Browser using JSP

I have tried to open a PDF file from the local disk.
For example the Location is:
E:/files/IT/cat1/cat1Notification.pdf
But during runtime the link changes to:
http://localhost:8080/Office_Automation/E:/files/IT/cat1/cat1Notification.pdf
How to do i get rid of http://localhost:8080/Office_Automation/ from the link and open the file?
I have used
click here
To open the local file you need to use the file scheme in your URL
As you path is a Windows path E:/files/IT/cat1/cat1Notification.pdf, the link's href needs file:/// added before the your jsp's <%=path%> variable, so that the browser knows it needs to open a local file on the user's machine.
So your link should look like this
click here
Which in your browser will resolve to file:///E:/files/IT/cat1/cat1Notification.pdf
Without the file scheme the browser assumes that your link is relative to the webpage and tries to resolve the link by making a request to your webapp. This is why you were getting http://localhost:8080/Office_Automation/E:/files/IT/cat1/cat1Notification.pdf