4 Replies Latest reply: Apr 30, 2012 2:22 PM by cj RSS

    show image in browser

    930387
      hi,
      i am new in PHP and oracle. can i show image in browser using image path from database?
        • 1. Re: show image in browser
          ChadThompson
          vikash wrote:
          hi,
          i am new in PHP and oracle. can i show image in browser using image path from database?
          Is the image itself in the database?
          • 2. Re: show image in browser
            930387
            No, Actually I m putting the path of image in database in varchar2 and i want to show image in browser using this path...plz help
            • 3. Re: show image in browser
              ChadThompson
              vikash wrote:
              No, Actually I m putting the path of image in database in varchar2 and i want to show image in browser using this path...plz help
              Gotcha - that actually makes life a little easier...

              What you'll want to do with PHP (I'll lay this out for you a bit - I don't have a code editor/environment handy at the moment..)

              1) You'll retrieve your image path from the database. Note that this path has to be the 'web accessible path', not a full file system path. (e.g. if your "Web Root" is /var/http/www and the full file system path to your image is /var/http/www/images/myimage.png, then the image you should have in the database is /images/myimage.png. This could also be a relative image path, etc.)

              2) Use your retrieved database path to insert into your HTML <img/> tag. If you have 'short tags' enabled, it should look something like this:

              <img src="<?= $myImagePath ?>" />

              That's the basics - is there anything here that sounds familiar?
              • 4. Re: show image in browser
                cj
                An off topic comment for general reference: In PHP 5.4, "<?=" is now always available regardless of the short_open_tag value.