SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Apr 2009
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help with Dowmload code

    Good day all, i've been trying to get files like jpeg, pdf to be downloadable on a click for download from my site. What i've been able to do just to get them to preview on the net. this files are heavy in MB & takes times to load on a browser. When u save as a jpg, and want to read, the pixels are so bad, u cant read them. The PDF files on thier own, takes more time to preview cos they are heavier than the jpg

    Plesae can someone help me with this download code, it could be n php or java. I would really appreciate it
    Last edited by peterokonji; Apr 28, 2009 at 04:52. Reason: To add to topic

  2. #2
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    do a search for php force download

  3. #3
    SitePoint Member
    Join Date
    Apr 2009
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    little bit confused with your question, do you mean want to download those files in a "new tab" ? if so, this code might help :

    PHP Code:
    <?php
    $name 
    basename($filename);
    $size getimagesize($filename);
    $len filesize($filename);
    header("Content-type: {$size['mime']}");
    header("Content-Length: $len");
    header("Content-Disposition: attachment; filename=$filename");
    readfile($filename);
    ?>
    Good luck

  4. #4
    SitePoint Addict bamaboy's Avatar
    Join Date
    Apr 2009
    Location
    Internet
    Posts
    224
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    so do you want that file rather to be downloaded than being watched out by users directly ?

    If yes, have a look Here
    Hymoo.com - Create Revolution - Help Us Spread The Word!
    Latest Wallpapers


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •