I have a PHP site that generates images. Doesn't matter if I use GD or Imagick
header('Content-Type: image/jpeg');
imagejpeg($source);
$img = new Imagick($source);
$img->setImageFormat("jpeg");
header('Content-Type: image/'.$img->getImageFormat());
echo $img->getImageBlob();
The image gets correctly served in the browser. But when I try to right-click and download it, Chrome wants to save it as "jfif" file. I understand that jfif is the file format, but I would like Chrome to default save it as "jpg" file. How can I change my PHP code so that Chrome does that?
Note 1: Chrome does allow to default save the file as "jpg" file when it is served directly as jpg-file from my web space.
Note 2: Firefox by default allows to save all my images from the website as "jpg". This is the behaviour I like to have.
Follow the below steps and check whether it's working or not.
Launch Registry Editor using Windows Search or Windows key + R pop-up window opens and type Regedit and press enter.
Navigate to HKEY_CLASSES_ROOT > MIME > Database > Content Type > image/jpeg
In the right panel, double-click on the Extension key. Its value should read as .jfif.
Change the value to .jpg and click Okay.
Close the Registry Editor.
The change should be instant and you should now be able to save JPG files from the web in .jpg format as it should be.
Related
I write HTML and CSS code in VS Code and for previewing it I need to open file explorer then files then double click them to open them in my default browser.
it takes too much time. is there any proper way for this?
I have tried one live extension called live server but the problem with it is we have to click the 'go live' button any time I want to refresh the code.
If the live server extension is the one by Ritwick Dey..
.. then then after clicking Go Live, it will open your page in the default browser and reload it automatically, every time you save your work.
in some cases, it is helpful to save the folder containing your HTML to a Workspace, in VS Code, especially if you are writing an app using the MVC modal and the HTML and CSS are in subfolders.
You can install an extension called open in browser.
After installation complete restart vscode and go to settings Ctrl + ,. Search for Open-in-browser setting and set your default browser as you can see below:
Then whenever you edit a html file, you can use shortcut Alt + B to open this file in browser.
Some browsers has the option to automatically save downloaded files to a folder, without prompting the user where to save the file. This has posed a problem for us where the user automatically saves the file in "Downloads" instead of selecting a proper location.
Is there any HTML-attribute, HTTP-header or JavaScript solution to instruct browsers to prompt for save location for downloaded files even though they are configured otherwise?
Note: I am well aware that this is probably not possible, but wanted to see if someone hopefully can prove me wrong.
Related issues:
How to make browser download link target instead of navigate: Force to open "Save As..." popup open at text link click for pdf in HTML
No. It's a browser preference. If the user prefers not to be bothered by their browser for download locations, then that's their prerogative. They'll deal with the file location after it has been downloaded. A server cannot influence that behaviour.
Is there a way for an HTML file or other format that when clicked, will open the default browser and navigate to a specified http:// web page, NOT a local file:// ?
<script>
location.href = 'www.someUrl.com'
</script>
Just create an html file that contains something like the above. When you click it you will be redirected.
At least for an HTML file, no. When you click on an HTML file, your computer will open it in your default web browser, and the URL at the top will will be a file:// as that's the location of your file. You can, however, include some JavaScript to redirect people.
<script>window.location = "https://www.google.com";</script>
That way people will open the local file, but they will be automatically redirected to Google.
Yes, a shortcut.
Create shotcut and type your browser application url and add link.
Example like this:
"C:\Program Files\Firefox\firefox.exe" "http://www.google.com"
Do you mean if there is a way to set your HTML files to a default web browser, so that when you double-click them, they'll open up in....lets say for example (chrome.exe, firefox, opera, etc etc...)? If so, I recommend you right click the HTML file and navigate to "open with", and choose the web browsing program you want to use.
If you really want to take the easy route. Download notepand++ text editor(notepad-plus-plus.org).
Here's a picture of how to run HTML file in notepad++ in the browser:
http://i.stack.imgur.com/Yuynt.png
Download
If I click Download button, this target blank is opening a new window.
But I need it to prompt a dialog for saving this file. How can I achieve this?
This is something that you cannot absolutely control with HTML itself.
If the user is having a browser with PDF reading capabilities (or a plugin) and the corresponding settings to open PDF files in-browser, the PDF will open like that.
The PDF opens in a new tab simple because of your target="_blank", which has nothing to do with a download prompt.
If you are using HTML5 you can use the download attribute:
Download
If you have a back-end service which you can control or you feel like fiddling with your Web Server, you can always look for setting the right Content-Disposition. See this SO question for some nice discussion on Content-Disposition.
I have uploaded a doc file on my server and when i open this file by it's url then it's automatically downloaded but i want that this should open in a browser instead of downloading,please help me to resolve this issue.
If you want open your document inside Browser, you can try the following settings:
The setting that controls this behavior is located in Windows Explorer (not Internet Explorer) on the user's machine.
Open “Windows Explorer”.
Select Tools -> Folder Options... from the menu.
Go to the “File Types” tab.
In the “Registered file types list”, select the file you want to change the setting for (e.g. DOC).
Click the “Advanced” button to open the Edit File Type dialog.
There is a checkbox, Browse in same window, where you can specify whether the selected file type should be opened within the browser or launched in its host application when clicked on a web page.
For more information, please refer to: http://support.microsoft.com/?scid=kb;en-us;162059
Have you tried to use the page view web part and link to the document?
Also, does it have to be a word document? Could you try a different approach for the content, like using one of the page layouts or the content editor web part?