1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

adding buttons

Discussion in 'PHP' started by PHPLOST, Nov 7, 2010.

  1. #1
    Is there a way to add buttons to a form, I have form that will display up to 6 pictures at a time and need a way to allow the user to select to download the picture. I currently have the user click on the picture to enlarge the view. But I need to be able to associate the picture with the button.
     
    PHPLOST, Nov 7, 2010 IP
  2. ThePHPMaster

    ThePHPMaster Well-Known Member

    Messages:
    737
    Likes Received:
    52
    Best Answers:
    33
    Trophy Points:
    150
    #2
    You can simply do the following:

    
    <a href="http://downloadLink"><input type="button" value="Download" /></a>
    
    PHP:
    Alternatively, you can use JavaScript onclick event, but do not see the reason in that.
     
    ThePHPMaster, Nov 7, 2010 IP
  3. bencummins

    bencummins Peon

    Messages:
    55
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    To force a download, you will need to send a header..

    i.e. you make a script on the server called download.php (see below) and then you can send the filename in, either via querystring/form post... (make sure you add some security to stop the user downloading ANY file from your system though!)

    download.php?file=123.jpg

    
    <?php
    $file= $_GET["file"];
    
    // security checks here! - make sure they are only trying to pull a file from the relevant folder
    
    Header("Content-Type: application/octet-stream");
    require_once $file;
    
    
    ?>
    
    PHP:

    N.B. As stated before, MAKE SURE you add some security in.
     
    bencummins, Nov 8, 2010 IP