Page 1 of 1

just want a picture!

Posted: Fri Jan 16, 2009 8:29 pm
by logike30
I am learning first off.. I have been having trouble trying to get this to function without help. Here is my issue:

I have an image's path info located in an a database. I want to display this image on the website.

Problem #1 - file is in format C:\images\sub-directory\photo.jpg
Solution #1 - $fixed_path = str_replace('\\', '/', $image_path);

This gives me - c:/images/subdirectory/photo.jpg. Fine.

So I echo this to the website inside of <img> tags to be viewed and nothing.. due to the fact that the file isn't under the htdocs directory I'm sure. Even when the images are placed in a sub-directory of htdocs I still have the full path of the image to work with which also results in no image displayed.

What I am attempting is to use the web browser to parse a directory full of images on my HD, add path and image information to a database then display each image. A learning endeavor, no real world use.

Is there a better way to skin this cat?

Re: just want a picture!

Posted: Fri Jan 16, 2009 8:39 pm
by Burrito
use open_dir() and readdir() to get the images and insert them to your database.

my suggestion would be to insert the path that you want to use rather than modifying it after you've selected your images. If you are hell-bent on doing it otherwise, you could explode() your path by "\" into an array then rebuild it to make it relative to your current path.