Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Sep 2010
    Posts
    124
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Problem with image getting from server file??

    hi this is my code

    image.php

    <?php
    require ('dbcon.php');
    $sql = "SELECT * FROM Upload_PPsample WHERE Internal='18'";
    $result = mysql_query("$sql");
    //mysql_close($link);

    ?>
    <img src="getImage.php?id='18'" width="600" height="200" />



    get.php

    $id = $_GET['id'];
    // do some validation here to ensure id is safe

    require ('dbcon.php');

    $sql = "SELECT * FROM Upload_PPsample WHERE Internal='18'";
    $result = mysql_query("$sql");
    $row = mysql_fetch_assoc($result);


    header("Content-type: image/jpeg");
    //echo $row['File'];
    echo dirname('../Uploads/files/$row['File']');



    images are save under Uploads/files


    please help me to display image in the webpage??

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,352
    Thanks
    61
    Thanked 528 Times in 515 Posts
    instead of using dirname(), use readfile() instead. PHP: readfile - Manual

    This will output the actual file not just the filename.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • #3
    Regular Coder
    Join Date
    Sep 2010
    Posts
    124
    Thanks
    6
    Thanked 0 Times in 0 Posts
    thankz for the help..

    please can give me sample code ..........

  • #4
    Regular Coder
    Join Date
    Sep 2010
    Posts
    124
    Thanks
    6
    Thanked 0 Times in 0 Posts
    thankz for the help..

    please can give me sample code ..........

  • #5
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,352
    Thanks
    61
    Thanked 528 Times in 515 Posts
    Quote Originally Posted by coolumanga View Post
    please can give me sample code ..........
    I just told you what to do. Highlight the word dirname, press the delete key then type readfile and save the file.

    If thats too complicated, I can do it for you for $100 via paypal.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!


  •  

    Posting Permissions

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