Is there anyway of opening html files directly at localhost on browser directly? - batch-file

I know it sounds weird but what I want is to make some automation on machine. I want any html file would be opening from .../htdocs/* should open in browser with http://localhost/*. How would I achieve this ?
Problem is not that it is not loading but what I want is clicking on html file would be started on localhost//... path rather than c://... path.
I tried to search using batch job but I don't know how to code in it so I am trying to learn it though I'm not sure whether it serves my purpose or not.

Related

How can I open a PDF file in Microsoft Edge browser

I know that the easiest way to open a resource in Edge is by using the microsoft-edge: protocol handler.
I think this works for html files. For instance, you could run microsoft-edge:http://stackoverflow.com to open Stack Overflow in Edge.
But, what if I want to open a PDF file?
Can I run microsoft-edge:file:///C:/Desktop/sample.pdf ?
Looks like it's not working for me.
Thanks
I could reproduce the problem on my machine, it seems that you want to open a PDF file in Edge browser from another browser. As far as I know, Edge browser URL protocol no longer works for local files, only for http/https.
As a workaround, I suggest you could upload the local pdf file to the internet, such as OneDrive. Then, we could get the shared link and use it with the Edge URL protocol.
Sample code as below:
Link

dart: How to save a file?

I need to save the file that is on my hard drive.
File address: /home/mk/proj1/1.txt
Program address: /home/mk/proj2/
I try to save:
new dom.AnchorElement(href: '/home/mk/proj1/1.txt')
..setAttribute("download", '1.txt')
..click();
Displays information about saving, but writes: Failed! No file.
How to save a file?
There is not really a way to save a file in the browser (except perhaps limited support for temporary files)
You can search for JavaScript solutions. They will be quite similar for Dart in the browser.
For example JavaScript: Create and save file
If you want to store a file on the client machine, you can provide a download link.
See also How to force a Download File prompt instead of displaying it in-browser with HTML?
To provide a download link for data that is available in the browser clients code instead of a server file, you can use a data url.
See also https://stackoverflow.com/a/29691487/217408

Invoke File save as prompt while Downloading in ExtJS

I want to invoke the file save as prompt while allowing the user to download a file in ExtJS from a URL.
Basically the idea is to allow the user to change the file name and select his desired location before saving the file on their machine.
Is there any way I could do this?
I do not want to use:
A server side code to send the headers.
Nor do I want to use the Flash-based Downloadify library to do this.
Also, <a> tag's "download" attribute does download the file, but it does not prompt the dialog box if the browser settings are not set right.
Is there any way apart from the above where we could handle the file download in our application?
No, it cannot be done with javascript alone due to the security restrictions of the contemporary browsers. You can read files but I have no knowledge of a way to save files directly from the javascript alone.
If your "I do not want tos" are not that strict, here you can find an example of file downloading. The essence is to send "Content-Disposition: attachment" header.

Access Specific PDF Page in WPF WebBrowser Control

I have a webbrowser control in my application that is used to display pdf files that have been created in iTextSharp and are stored locally on the hard drive.
I would like to be able to navigate the file (next, previous, first, last, toc) from my application rather than using the inbuilt nav of the reader in the browser.
I have seen that you can navigate to specific pages by using
Browser.Navigate("filename.pdf#page=?);
This works the first time but when trying to navigate to a different page, it makes the browser disappear completely with no errors. However, I can reload the file without problem if I don't have the #page=? suffix on the file url though. Any ideas on this?
Alternatively, is there anyway in iTextSharp of adding something to the file to allow for it to be navigated from an external command?
All the official parameters that can be used to navigate through a PDF using parameters in the query string after the ? character are listed in a document published by Adobe: Parameters for Opening PDF Files
You already mentioned the page parameter. Another option could be using named destinations: nameddest=destination. In this case, you need to add the anchor with name destination to the file using iTextSharp.
Note that not all viewers implement these parameters. Adobe supports them in Adobe Reader and in the Adobe Reader plug-in, but there is no guarantee that they will work in pdf.js (Firefox), Pdfium (Google Chrome),... If your browser disappears when using an open parameter, you may have hit a bug in the browser or the viewer plug-in that causes the browser to crash. iTextSharp nor iText can crash a browser ;-)
There are no other ways you can navigate a PDF from an external application. The only thing you can do, is to add JavaScript to the PDF so that it always opens at the same page. This is done using an open action. I don't think this solves your problem as it would mean that you have to change the PDF file every time you want it to open at a different page.

different way to upload file

Is there a way to upload a file by copying a file from the desktop and pasting it into a text input which will obviously just display the filename, rather than going through the file window and selecting the file?
Talking about web applications, that could be possible if you install a custom ActiveX object or even a Java applet, or maybe trying to exploit a browser vulnerability. But, most straight way to do that will be using a <input type='file'>
For client applications, you can do that, if your current user have appropriate permissions, like accessing your file system and accessing your web server through HTTP.
Anyways, you must provide more details to get more concrete answers.
I think this is not possible and should not be possible as this is a security issue. Consider the following scenario:
A malicious site example.com shows you a harmless looking form where they have hidden such a file upload textfield with the already inserted value '/etc/passwd'. They have used either a hidden_field or just display:none with CSS.
You fill in the form and submit without knowing you have also sent a file.

Resources