Results 1 to 8 of 8

Thread: PHP code to call image

  1. #1
    Am I Bitter?...Absolutely nicedreams's Avatar
    Join Date
    Apr 2004
    Location
    Washington DC Metro
    Posts
    572

    PHP code to call image

    I'm trying to call a jpg image that is in a directory above my html dir. How can I get that jpg file and use it in an img tag?

    Jimmy

    Gay Amateur Paysites / Solo Twink Paysite
    Nice Dreams Cash
    http://www.nicedreamscash.com


  2. #2
    Moderator Bec's Avatar
    Join Date
    Nov 2003
    Location
    Ohio
    Posts
    8,419
    Wish I had an answer for you, but I tossed the thread to Develish who may have a clue how to structure the tag you need.


  3. #3
    Corey Bryant
    Guest
    I know on Windows, that if I am calling a file above my root - I need to use an absolute URL, like d:\domains\coreybryant.org\wwwroot\default.asp and the image would be in the folder d:\domains\coreybryant.org\secureimages\filename.j pg

    Also the IUSR needs to have access as well (I think). I don't know if that us a start until someone comes in with PHP knowledge. Sorry I mainly do ASP and rely on the programmers for most of that


  4. #4
    Life is a dick and when itīs get hard---just fuck it... DEVELISH's Avatar
    Join Date
    Jul 2005
    Posts
    2,367
    I'd use a script reading out the image and displaying it - I try to dig one out

    Dunno if it may be done otherwise - chilihost is more webserver savy than I - i try to write my own tools
    :-D


  5. #5
    Am I Bitter?...Absolutely nicedreams's Avatar
    Join Date
    Apr 2004
    Location
    Washington DC Metro
    Posts
    572
    Thanks for the replies. I was able to use a script to pull and display the image.

    Jimmy

    Gay Amateur Paysites / Solo Twink Paysite
    Nice Dreams Cash
    http://www.nicedreamscash.com


  6. #6
    Life is a dick and when itīs get hard---just fuck it... DEVELISH's Avatar
    Join Date
    Jul 2005
    Posts
    2,367
    oh darn

    I was to slow - gimme a gun to my head - but for the others:

    heres a way to do it

    PHP Code:
    <?php

    $imgpath 
    '/path/to/images/'//webserver user needs read access to this folder

    if ($imgname != "")
    {
       
    $im = @imagecreatefromjpeg($imgpath.$imgname); /* Attempt to open */
       
    if (!$im) { /* See if it failed */
           // if the call of the image failed create a nice little image with the error message
           
    $im  imagecreatetruecolor(15030); /* Create a black image */
           
    $bgc imagecolorallocate($im255255255);
           
    $tc  imagecolorallocate($im000);
           
    imagefilledrectangle($im0015030$bgc);
           
    /* Output an errmsg */
           
    imagestring($im155"Error loading $imgname"$tc);
       }
       
    imagejpeg($im);
    }


    ?>

    Untested but it should do the work
    :-D


  7. #7
    Corey Bryant
    Guest
    Just in case - I totally forgot about Calling files outside of the public_html on server as well. The other solution might be a solution as well but not knowing PHP I thought that thread could help


  8. #8
    marcjacob
    Guest
    Why not just use html? Im obviously missing something? like <img src="../image.gif"> or use the full web address?


Posting Permissions

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