Need Help to Disable Download from a URL - html

Is there a way to disable a user from downloading a file from a URL?
For example I have a link:
wow.mywebsitedomain.com/templates/filename.svg
I want to disable the user from downloading the filename.svg
These svg files are not just an image, they are editable designs that I have spent countless hours on each. No, I do not care if someone does a screenprint or gets a png etc, as those are not scalable, editable, vector files.
When the user clicks on a png thumbnail my actual link opens my online design editor to allow the user to customize these files, then save to my server, then purchase printed media, and they are not allowed to download any files.
I tried putting the actual files into a password protected folder on my server, but they do not open properly, and I do not want the user to have password access to this folder.
Essentially I need the link to be accessible, just not show the actual link for someone to copy and open/save/download etc.
Hopefully there is a simple solution for a non-programmer with basic html skills?
Thanks

Your can do things like "disabling right-click" and stuff - it may prevent some users from downloading your file, BUT basically you cannot prevent a file which is downloaded and interpreted by the browser from being downloaded to a user's hard drive.
This is not only true for SVGs, but also for music, videos, etc.
Instead, you can convert your SVG file to a PNG on server-side, and show only the PNG to the user. Note that you have the possibility to create PNGs of different sizes on the fly - dependent on the request, user's screen resolution, etc. You can also implement caching of the generated PNGs if needed.
On how to create a PNG from SVG in PHP read here:
Convert SVG image to PNG with PHP
You can choose other raster image format, of course.

If they can view it, they can download it. End of story. If you only want them to see a PNG, make a PNG from it and put that up

My understanding is; if you can see it, you can download it,

Related

Truly undownloadable images

I had given up on protecting online images since even disabling the easiest ways to get at images still left people the option to use Inspect, then Sources, and poke around in the folders until they found the right file, hey, presto.
The only real way to get around that was to break the image up into tons of fragments so you're just depending on people not being able to code and getting bored with the idea of putting the image back together.
This site, however, has a public domain image that has somehow truly blocked the Inspect hack: The image appears within Inspect (d7... folder, 3rd image) but any attempt to open or download that image just produces useless "download" files instead of the actual image. How'd they pull that off? and why isn't it more common? How expensive/time consuming would it be to implement for online image databases?
The image appears within Inspect (d7... folder, 3rd image) but any attempt to open or download that image just produces useless "download" files instead of the actual image.
I managed to download it (using qutebrowser) by opening in new tab. The filename was qwe_download.
When i opened the image in my file manager (Thunar), it showed as WebP image.
I used feh (image viewer) and it was exactly the image.
Maybe use WebP compatible image viewer to open the file.

How to display local images

Working on a ASP.Net MVC project, I've got a page that allows users to upload their own picture. On the database, it is stored a file path, such as C:\zm\zemanel.jpg
After some research, it seems that browsers can't access the local machine and for that reason, if I have this:
<img src="C:\zm\zemanel.jpg"/>
The image isn't displayed. Note that it is still in development, the path leads to my machine (localhost).
What is the best solution for the user to select an image, have its path stored in the database, and the image to be displayed?
Can the image be included in the project dynamically? Say for example, in the Images folder?
Because images stored in a project folder are displayed normally.
I'm assuming you want to keep that image for future use (saving projects, etc). So sorry if it's overly complex for what you are asking.
I would think that the easiest way to handle this is to just use an input tag. With that tag you can use certain attributes to select a type of file to show in the client dialog, example[Example]:
//accept tag may not work with older versions of IE
//This shows how to open a client side dialog which defaults to an 'image' filetype.
<input type="file" accept="image/*"></input>
As mentioned by others, you would then upload the file, manipulate it (create a thumbnail or whatnot) then insert the image to the page using either a page refresh or javascript to call an ajax request and insert the image.
Any functionality beyond that you'll probably need a Java applet or custom control, which to me seems like overkill.
Try
<img src="file://c:\zm\zemanel.jpg" />

Do not show the URL in page source

I have some copyrighted audio files that I would like to protect from download, but show them on the website(drupal).
I have a player that works with flash and css on a link, but if you view the page source the href of the link is visible, and it is very easy to get the URL and get the files locally.
I understand that it's not possible to prevent it 100%, but what I would like to do is just to make it more difficult than seeing the url in the page source.
How can I do it?
I would like to avoid to write myself a player, because my flash knowledge is quite limited...
I'm already hidding with Javascript the link while hoovering with the mouse of the player(which is acctually a link in terms of HTML).
I've tried an HTML obfuscator(http://htmlobfuscator.com), but it does not work properly, for one link it works, for the second and third one it doesn't...
Many thanks
Ultimately, any file which is simply embedded has to be downloaded to the user's computer in order to be played (usually it is downloaded to a temporary location then removed, but a savvy user will be able to capture the download and save it.
If you want any real protection, you'll have to use a streaming server like Helix Streaming Server. With these, the file is not downloaded by default and the user's only real capture option is an audio cable from LineOut to LineIn. Most don't have access to this.

Saving image without extension

I have worked on many web apps that allow a person to upload and display images (like profile images, background image, etc). A problem I have come across is that you usually provide specific formats that the user can use (i.e jpg, png, jpeg, gif, etc).
Problem is, that suppose you have a profile picture, some may upload a jpeg, some png, and some gif. What format should you save the file in? i.e 'profile.jpeg', 'profile.png' or simply 'profile'.
I noticed that you can simply exclude the file extension and the browser opens the image, but is this safe?
The file extension does not determine the file format. You can upload a .gif that ends in a .png and the browser will display it with no difficulties. (You can also use .exe or .foo or whatever, and the image will still display.)
In other words, the extension has nothing to do with security.
On the other hand, I'm not aware of any security risks in passing an unknown file to the browser to display as an image. If you have <img src="virus.exe">, the browser will do nothing because the file is not a valid image file.
If you want to be sure, you could check on the server that the uploaded file is a valid image and discard if it's not.

How to make download PDF html code download on computer

I'm creating a button which will download an original file in a PDF format. I already have a zoom button if they want to read the PDF via the browser. But I want to offer the possibility to the user to download the file if he prefers, obviously the downloadable file will have a higher quality.
I've tried some basic coding but the problem is that the PDF is opened in the browser. I'm not using any CMS and won't in a future, so the photos are uploaded simply via html code and by placing the picture in the correct file, so no database is present. This is the code I'm using in this moment:
<img class="icons_infobox" src="./_img/prensa/icon_download.png" alt="Download original file" />
This website needs to be cross-browser compatible so I also will ask the answer to be browser friendly.
Thank you very much!
Hello curious people!!!
After gathering and investigating what could be done I've found some answer. I will give as an answer only two options:
100% sure it downloads but not so nice for the user
-Only sure way is converting the downloadable files into .zip. Yes its not too handy/elegant but that is for sure the way the browser will be obliged to download this file. ZIP format files are always downloaded.
Depends of the users browser preferences
-Yes, you cannot be completely sure but its a very close approach. You will need to create a .htaccess file in the folder where you have your PDF for download. You would need to create this file and place it in with the following code:
SetEnvIf Request_URI "\.pdf$" requested_pdf=pdf
Header add Content-Disposition "attachment" env=requested_pdf
I hope this helps somebody. In my web it did work perfectly. It divers between browsers but it works... You just need to know that there will be a porcentage that will see it displayed in the browser and not downloaded.
Greeeeetings,
Dani