Creating a jpg download link

Is there a way to
have a link download a photo jpg as opposed to displaying the photo in the browser?

If you are using Apache as your web server, create a new text file and name it ".htaccess"
Include this in that new text file:
<FilesMatch "\.(?i:pdf|jpg|gif|txt|doc|exe|dmg|zip)$">
      ForceType
application/octet-stream
      Header set Content-Disposition
attachment
</FilesMatch>
Note that the first line includes all the filetypes that you want to force as downloads, separated by "|".
Then create a new directory on your server to hold the downloadable files, such as http://www.yourdomain.com/downloads
Save the .htaccess file to that new download directory. Do not save it to your web document root.
Save your files that you want to download in that new download directory.
Link to those files from your regular HTML pages.

Similar Messages

  • Creating a file download link on jsp

    I have the following on my jsp. The code worked fine until I tried to use it in a new html design page.
    <code>
    //page name is index.jsp
    try //DISPLAY THE CONTENTS OF THE DATA DIRECTORY
    File dirname = new File(PATH); // create an instance of the File class
    if (dirname.exists()&&dirname.isDirectory())//check to see if File class dirname exists and is valid
    String [] allfiles = dirname.list();//create an array of files in the dirname File class
              for (int i=0; i< allfiles.length; i+=2)//loop through allfiles[] and print out file links
    out.println("<br><table border='1' cellspacing='1' width='99%'>");
                   out.println("<tr><td width='50%' class='pageFont'><input type='checkbox' name='cb' value='"+allfiles[i]+"'>"+allfiles[i]+"      ");
    %>
    <a class="a" href="index.jsp?downfile=C:\\data\\<%=allfiles[i+1]%>">DOWNLOAD</a></td>
    <% if(i+1 < allfiles.length)//PRINTS OUT THE SECOND TD SO THAT WE HAVE 2 COLUMNS OF LINKS
    out.println("<td width='50%' class='pageFont'><input type='checkbox' name='cb' value='"+allfiles[i+1]+"'>"+allfiles[i+1]+"      ");
    %>
    <a class="a" href="index.jsp?downfile=C:\\data\\<%=allfiles[i+1]%>">DOWNLOAD</a></td></tr>
    <%
    out.println("</form></font></table>");
    catch (IOException excep)
         out.println("An IO exception has occured.");
    </code>
    Then when clicked this code is run:
    <code>
    try{
    //CHECK TO SEE IF THE FILE HAS BEEN CLICKED TO DOWNLOAD SINGLE FILE
    if (request.getParameter("downfile") != null)
    String filePath = request.getParameter("downfile");
    File f = new File(filePath);//CREATE AN INSTANCE OF THE FILE CLASS AND POINT IT TO THE LOCATION OF THE DIRECTORY CONTAINING THE FILES
    if (f.exists() && f.canRead())
    response.setContentType ("application/octet-stream");
    response.setHeader ("Content-Disposition", "attachment;filename=\""+f.getName()+"\"");
    response.setContentLength((int) f.length());
    BufferedInputStream fileInputStream = new BufferedInputStream(new FileInputStream(f));
    int i;
    out.clearBuffer();
    while ((i = fileInputStream.read()) != -1) out.write(i);
    fileInputStream.close();
    out.flush();
    </code>
    When I click on this link I get the download dialog box. If I open it I get the following open up in notepad(the files I am trying to give download links are .txt files)
    Below is what is displayed in notepad ALL on 1 line:
    <html>
    <head>
    <LINK rel="stylesheet" ty
    That is displayed in all of the links that I click on. It is the first few lines of html code for index.jsp.
    I know this code is probably not a good way of doing what I need but I got it to work fine until the change.
    I am sure there is an easier way to code the download link without resubmitting the page.
    Thanks in advance!!

    Well all was fine with this jsp until I moved it to ApacheJServ. Now the problem has resurfaced(although it is a little different now)
    I had moved the following code to the top of my page:
    //CHECK TO SEE IF EITHER DOWNFILE OR ZIPFILE VARIABLE EXIST, AND IF THEY DO SET CONTENT TYPE BEFORE SENDING ANY HTML CODE TO THE BROWSER
    try{
    //CHECK TO SEE IF THE FILE HAS BEEN CLICKED TO DOWNLOAD SINGLE FILE
        if (request.getParameter("downfile") != null)
                String filePath = request.getParameter("downfile");
                File f = new File(filePath);//CREATE AN INSTANCE OF THE FILE CLASS AND POINT IT TO THE LOCATION OF THE DIRECTORY CONTAINING THE FILES
                    if (f.exists() && f.canRead())
                        response.setContentType ("application/octet-stream");
                        response.setHeader ("Content-Disposition", "attachment;filename=\""+f.getName()+"\"");
                        response.setContentLength((int) f.length());
                        BufferedInputStream fileInputStream = new BufferedInputStream(new FileInputStream(f));
                        int i;
                        out.clearBuffer();
                        while ((i = fileInputStream.read()) != -1) out.write(i);
                            fileInputStream.close();
                            out.flush();
                            response.flushBuffer();
    catch (Exception e){}
    //This is where the java code ends and the javascript/html code begins.Then further into the page I create the file download links like so:
                            <a class="a" href="main.jsp?downfile=C:\\data\\<%=allfiles[i+1]%>">DOWNLOAD</a>I know this isnt a secure way of doing this but I am on a intranet.
    The problem I am having now is that when I click on one of the links and download the file and then open it, I get the contents of the file plus concatenated to the end of it is the first few HTML lines of the actual jsp that I downloaded the file from. Before I was just getting the first few lines of html from the jsp, not the actual contents of the downloaded file.
    This is an example of what I am getting:
    This is the contents of the file that I downloaded.//This is where the file contents ends.
    <html>
    <head>
    <LINK rel="stylesheet" type="text/css" href="default.css">
    <script language="JavaScript1.2">
    //function that allows user to select all checkboxes
    function doIt(v)
    for(var i=0;i<document.form1.cb.length;i++)
       document.form1.cb.checked=eval(v);
    function swap(imageName,image)
    imageName.src = "templateImages/"+image;
    function imageOver(imageSrc, imageName)
         changeImage = new Image();
         changeImage.src = imageSrc;
         document.images[imageName].src = changeImage.src;
    var hide = true;
    function hideShow( ) /
    Any morre ideas?
    TIA!
    BTW, I went to ApacheJServ because they wont let me use tomcat :(

  • How  to  create a direct  download  link  ?

       Hello,I want to download a trail product from Adobe,but I do not want to use Adobe Download Assistant  for its poor download speed.I want to creat a link such "http://trials2.stage.adobe.com/AdobeProducts/PHSP/13/win32/Photoshop_13_LS1.7z".But when I click it,it shows that
    Access Denied
    You don't have permission to access "http://trials2.stage.adobe.com/AdobeProducts/PHSP/13/win32/Photoshop_13_LS1.7z" on this server.
    Reference #18.e4c18d3f.1360043436.1274112
    Why? and I want to know where I can  download product.Could you please  offer an website  like  "ftp://ftp.adobe.com"  ?
    Thanks!

    I got it,thanks a lot Mylenium.
    But,I want to know  when I clik this link,
    "http://trials2.stage.adobe.com/AdobeProducts/PHSP/13/win32/Photoshop_1 3_LS1.7z",it shows me
    Access Denied
    You don't have permission to access "http://trials2.stage.adobe.com/AdobeProducts/PHSP/13/win32/Photoshop_1 3_LS1.7z" on this server.
    Reference #18.e4c18d3f.1360043436.1274112
    Why?

  • How to create an mp3 download link (AS3)

    I'm having a lot of trouble figuring out how to let users
    download mp3s from my flash website (so the user gets the same sort
    of dialogue box that they would from a normal html site). Part of
    the issue is that I have a very, very piecemeal knowledge of as3
    and flash. So far, it's been a couple of tutorial books and a lot
    more ambition than knowledge : ) With that being said, I would
    greatly appreciate not only the answer, but an explanation of how
    and why the answer works. The tutorial books I used really dumbed
    down as3, so the "correct" way is much different than what I
    learned. Thank you so much in advance, and I really appreciate the
    help!
    Thanks!
    Dave

    Zip up the MP3 then link to it.
    Regards
    FlashJester Support Team
    e. - [email protected]
    w. - www.flashjester.com
    "This has been one of the most impressive and thoroughly
    pleasant
    experiences of customer support I have ever come across -
    astounding!"
    Director - hedgeapple

  • Sharepoint 2013 - How to add "download link" to a column

    Hi there.
    We have download library with video files. We would like to add a column with a hyperlink of files in other words: DOWNLOAD LINKS.
    What would be the easiest way to achieve that?
    with best regards,
    bostjanc

    Hi Bostjan,
    you can create a workflow that, on item create, sets your download link column with this value:
    http://<your site collection url>/_layouts/download.aspx?SourceUrl=<your file url>
    hope this helps.
    Fabio

  • How do I create a downloadable link from an Interactive PDF file created out of InDesign CS6?

    Hello,
    I created an Interactive PDF file out of InDesign and would like to make the large file a downloadable link and share it with the user in an email. I do not want to use DropBox or GoogleDrive.
    The company I contract for has their own site - do I insert the file into the site or can I create a separate link for it?
    I will be recreating these presentation PDF's constantly, so I would like to know if there is a simple way to create this link for files in the size of 7-12MB.
    Any ideas on downloadable links? I do have flash - but rarely use, perhaps load the file out of flash?
    Thank you so much for your help,
    Megan

    Hi Willie,
    Thanks for your help. Most likely contact the company who maintains the
    site then to share the file with them I'm assuming?

  • Error when using format mask to create download link in report

    I'm following these directions to create a download link in a report region.
    http://docs.oracle.com/cd/E23903_01/doc/doc.41/e21674/advnc_blob.htm#HTMDB25905
    ######### Table Structure...
    desc document_library
    Name Null Type
    DOC_ID NOT NULL VARCHAR2(40)
    DATE_ADDED NOT NULL DATE
    FILE_CONTENT BLOB()
    FILE_NAME VARCHAR2(100)
    MIME_TYPE VARCHAR2(100)
    DOC_NUMBER NUMBER
    ###### Report Region...
    select a.*, dbms_lob.getlength(file_content) length
    from document_library a
    ###### Download Link Column...
    Date Format: DOWNLOAD:DOCUMENT_LIBRARY:FILE_CONTENT:DOC_NUMBER::MIME_TYPE:FILE_NAME:::attachment:Download
    ####### Results...
    report error:
    ORA-06502: PL/SQL: numeric or value error: character to number conversion error
    The report region displays no rows (even though there is one row in the table), no links, and even more strange, it show the value of APP_USER where it would normally display the results.

    Josh,
    Your end result on page 58 and the instructions in that document link don't seem to correlate. Regardless, I:
    1) Copied page 58 to page 158 in your application.
    2) Removed the BLOB format mask from your report link.
    3) Changed your query to:
    select "ROWID",
    "DOC_ID",
    "DATE_ADDED",
    "USER_ID",
    dbms_lob.getlength("FILE_CONTENT") "FILE_CONTENT",
    "FILE_NAME",
    "MIME_TYPE",
    "DOC_NUMBER"
    from "#OWNER#"."DOCUMENT_LIBRARY"
    4) Specified the BLOB format mask for the FILE_CONTENT column.
    Seems to work just fine now (on page 158, that is).
    Joel

  • Creating Downloading Link

    Dear All
    I'm trying to create a downloading link in my iweb using HTML snippet. I created the following code in the snippet
    a href=Movie.mov> Movie
    (I removed the "<".mov" files.
    However, it does not work in Mac ! When I right click and selected download, it downloaded the following "Movie.mov.html". Notice the ".html" extension... for some reason I cannot download the file as a ".mov" file and Mac doesnt allow me to change the extension. FYI, I can play the move in the browser but unable to download unless I have quicktime pro... I do not want users of my website to be buying quicktime pro just so that they can download my files.
    Is anyone able to help ? What changes in my coding do i need in order to allow both PC and Mac users to download ??
    Please help.. thanks a million.
    Jojos

    There are two ways of doing this without any coding. Go to ......
    http://www.iwebformusicians.com/iWebMusicWebsite/iWebTutorials.html
    ... download the tutorial Domain Files and Downloads and look at page 4.

  • HT204053 So where is the download link and how do I create and account

    How does this work.  I can't find a download link anywhere for iCloud for the mac.  What is the deal?

    iCloud isn't a program, it's an online service, and there is no download. You sign into it in System Preferences (or Settingds)>iCloud - however the minimum requirement is Lion 10.7.5 on a Mac or iOS5 on an iPhone or iPad. If you have earlier systems than that you will need to upgrade.
    According to your signature you have iOS6 so you're good to go. You have an Apple ID which you are using here; so just go to Settings>iCloud and sign in with your ID. Enable Mail, Calendars, Contacts etc as required in that preference page. You will be asked to create an @icloud.com address.
    If your Mac has an earlier system than 10.7.5 it won't be able to joing the party until you upgrade. The following information applies in that event:
    To make full use of iCloud you will have to upgrade your Mac to Lion or Mountain Lion, provided it meets the requirements.
    The requirements for Lion are:
    Mac computer with an Intel Core 2 Duo, Core i3, Core i5, Core i7, or Xeon processor
    2GB of memory
    OS X v10.6.6 or later (v10.6.8 recommended)
    7GB of available space
    To purchase it you will have to ring Apple at the number given at the bottom left of this page.
    The requirements for Mountain Lion are listed here:
    http://www.apple.com/osx/specs/
    It is available from the Mac App Store (in Applications). (If you are currently pre-Snow Leopard you will have to upgrade to that to access the Mac App Store: it's available in the online Apple Store.)
    You should be aware that PPC programs (such as AppleWorks) will not run on Lion or above; and some other applications may not be compatible - there is a useful compatibility checklist at http://roaringapps.com/apps:table

  • XML Forms: how to create download link

    Hi,
    can anybody tell me, how i can create a download link to a document rid
    in an XML form?
    I can create a link which will open the referenced document, but "right klick
    link | save target as..." will produce an error, since the link is a javascript call.
    Thanks for any help,
    bye,
    Markus Steinberg

    Hi Markus Steinberg,
         i need to create the Download attachement Option In XML Form..
         U got the solution for that above thread..
         If so please tell me how to create? and then how to create multiple Link ?
    Regards
    Thillai J

  • How do I create an Adobe id link between my home computer and my computer at work? Want to be able to read books i download at home, at work.

    how do I create an Adobe id link between my home computer and my computer at work? Want to be able to read books i download at home, at work.how do I create an Adobe id link between my home computer and my computer at work? Want to be able to read books i download at home, at work.

    In that case, does anybody know of a program or workaround that will make this so?

  • Download link for images

    What is the solution to create a download link that will
    automatically start to download to the hard disk or ask where to be
    saved (ie. Desktop, Downloads)? What I don't want to happen is to
    have the image open in a new browser window. I have .eps, .tif and
    .jpg files. Is this hard to do? I can't find any help anywhere on
    the net for this problem.

    .oO(A Dion Lainy)
    >What is the solution to create a download link that will
    automatically start to
    >download to the hard disk or ask where to be saved (ie.
    Desktop, Downloads)?
    >What I don't want to happen is to have the image open in
    a new browser window.
    >I have .eps, .tif and .jpg files. Is this hard to do? I
    can't find any help
    >anywhere on the net for this problem.
    Well, usually the preferred way is to just link to the image
    or another
    file and let the browser/user decide what do with it.
    If you still want to "force" a download, the easiest way for
    you as the
    author is to simply zip the file(s). In most cases this will
    cause a
    download dialog, but also creates another hurdle for the
    user, because
    he has to unpack the file before he can use it.
    Another way - a bit more complicated for you, but much easier
    for the
    users - would be to deliver the files with another content
    type like
    "application/octet-stream". This should also cause a download
    dialog.
    How to do that depends on the capabilities of your server. It
    can be
    done with scripting or even with just a simple AddType
    directive in an
    .htaccess file on Apache servers.
    Micha

  • I need to create a button that links to another swf file...

    i'm creating my first website, and, for each menu item, i am
    creating a new flash document... is this the correct way to create
    a multi-page website?
    plus: how to create a button that links to a jpg, thanks!
    jane

    Creating separate swf's these days as far as I know is
    considered to be a better practice than using the "scenes" that are
    in Flash. The reason is you can load various sections of your
    entire Flash entity rather than the user downloading everything at
    once.
    But, it also depends on the complexity of where your menu
    items are leading. If they are simple enough, then there may be no
    need to create new documents.
    To create a button that links to a jpeg, try this.
    Whatever graphic you're using for the button, select it and
    hit F8 to convert it to a movie clip. Once it's in your library,
    click on your new movie clip on the stage and give it an instance
    name in the properties window.
    Click the first frame in your timeline (preferably on a layer
    named "actions") and put this example in for the actionscript:
    //buttonName is the instance name you gave it
    //.onPress tells Flash when buttonName is pressed then do
    what's
    //inside the brackets of the function
    buttonName.onPress = function (){
    //getURL is the Flash function that will load your
    picture.jpg
    //_blank is the target. e.g. _blank, _self etc.
    getURL("picture.jpg", "_blank");
    }

  • How to make downloadable links in Adobe Muse

    I am new to website design and am trying to figure out how to make downloadable links for some PDF flyers, PSD templates I am creating.   Not sure if "downloadable links" is the correct term for what I'm trying to say but in a nutshell I am creating Business Flyer's in PDF form and Photoshop PSD template files that I would like to be able to have my users click a link that allows them to download them right to their desktop.  Any help would really be appreciated!

    Hi caybar10gaming,
    I had the same question as you and was searching online for how to add "downloadable links" as well so your not alone in that lol. Anyways, I found this video that explains how to do this. I hope this helps you, as it did me. Good Luck  
    http://tv.adobe.com/watch/muse-feature-tour/add-and-link-to-any-type-of-file/
    -Caitlin

  • Download link not working in Adobe AIR app.

    I wanted to let users browse my site as a desktop application,
    but didn't have the time to write an application from scratch. SO tried following trick. Created a simple Adobe AIR application with a single page. This page redirects to my website and hence loads the website in the AIR window.
    Everything is working fine except that the download links are not working. The download doesn't start. Nothing happens. What is the solution here? Any help is appreciated.

    I am now facing the same problem. I wrote a servlet .
    code like this
             response = (HttpServletResponse) faces.getExternalContext().getResponse();
             response.setContentType("application/x-download");
             String agent = request.getHeader("USER-AGENT");
             boolean isIE=false;            
            if (null != agent && agent.indexOf("MSIE")!=-1) { 
                isIE=true;
            if (isIE) {
                fileName = URLEncoder.encode(fileName, "UTF-8");
            } else {
                fileName = new String(fileName.getBytes("utf-8"), "ISO-8859-1");
            response.setHeader("Content-Disposition","attachment;filename="+fileName);
            ServletOutputStream os = response.getOutputStream();
            byte b[]=new byte[1024];
            int n;
            while((n=in.read(b))!=-1){
                os.write(b,0,n);
           in.close();
           os.close();
    and i open a new window refer to above jsp ,also i set a breakPoint at os.close(),the program has passed through,but nothing happened in the window.
    If i use IE or FF ,the browser will open a small window to allow me select whether open or  save the file.So can anybody give me some advice.Is it because air using webkit engine and the engine does not do this kind of job?
            Thanks.

Maybe you are looking for

  • How do I speed up my MacBook Pro 3,1 (2007)

    I have a MacBook Pro 3,1 (year: 2007) running on OS 10.6.8 (Snow Leopard) and a 2.2 GHz Intel Core 2 Duo processor. It has a 1.5 GB 667 MHz DDR2 SDRAM with a bus speed of 800 MHz. It is still in good running condition and I am reluctant to let go of

  • Accessibility feature not working as it should

    I have an iPhone4 with accessibility turned on, at the SIM unlock screen the phone has recently changed behaviour from select a number then double tap to type, to press and briefly hold number to type.  For a blind user, I need this changed back to t

  • BUG!: JDeveloper 11g Tutorial code is incomplete.

    I am attempting the complete the JDeveloper 11g Tutorial from the Fusion Developer's Guide for Oracle Application Development Framework After adding all the latest jars available from the ADF Installer to the StoreFrontModule I am left with 10 errors

  • How to resolve SCOM event 1102

    i have deployed a test environment on my local machine and am using scom 2012 r2,it is throwing all 1102 error health service in bulk events rule\monitor cannot loaded,how can i resolve this issue,i  went through many forums but am unable to resolve

  • What tech. do I need just to generate PDFs based on ABAP function modules

    Hello, We have mySAP ERP 2005 and Enterprise Portal 7. Until know we offered employees (in the portal) to print some "reports" such as travel data and payslip. We used the functionality to convert a spool job into a PDF in this case. Now, we want to