SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2007
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    a little problem with uploading images

    I have an upload form and a page to download/display the uploaded images.
    everything used to work till now.
    now when i'm uploading a new image, it is being stored in the database like it used to be
    but it won't display the image on the page.
    when i type the display page directly in order to download the image, instead of downloading the image
    it downloads the page itself (display.php)
    i tried uploading images i've already uploaded before. the size and everything is the same
    but still, the old once work fine while the new once don't.
    maybe it has something to do with a database backup i've done recently.

    display.php:

    PHP Code:
    <?php
    require_once("../includes/classes.inc.php");
    if(isset(
    $_GET['id']))
    {


    $id    $_GET['id'];
    $id = (int)$id;
    $query "SELECT name, type, size, content " .
             
    "FROM images WHERE id = '$id'";

    $result $db->sql_query($query) or die('Error, query failed');
    list(
    $name$type$size$content) =   $db->sql_fetch_array($result);
    header("Content-length: $size");
    header("Content-type: $type");
    header("Content-Disposition: attachment; filename=$name");
    echo 
    $content;
    exit;
    }

    ?>
    any ideas?

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Do some debugging. Comment out the header() lines so you can see if "Error, query failed" printed, and if $content printed.


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
  •