0

Just a quick questions guys. I'm using a 'browse' upload function within a form to select and upload a picture to my database. At the moment my images are in a 'Image' folder and to get them to show I need the following within my Image column:

Images\picname1.jpg

When I use the browse upload function, I get the following:

E:\xampp\htdocs\IDB\images\picname1.jpg

which is the displayed on the database as:

picname1.jpg

And of course as the 'Image' folder directory isn't included, the image will not display.

This is my form:

<font face="Arial"><b>Enter Image(Optional):</b></font><input type="file" name="imaAdd"   accept="image/gif">

Could anyone tell me how I can include the 'Image directory!? I'm sure its an obvious fix I'm missing!

Any help would be great!

Edit:

Hers my Image echo guys.

    echo"<img src='".$row->Image."'>";
1
  • Can we see the code on how you display your image? Commented Apr 19, 2012 at 2:45

2 Answers 2

2

One option would be to concatenate the string 'images/' with the image filename upon insertion into your database.

A better option would probably be to qualify the filename with the images path when you go to display the image. If you can show us the code you use to display the images, it should be an easy fix.

The PHP code for this latter option could look like:

echo '<img src="images\' . $imagename . '" />';

Sign up to request clarification or add additional context in comments.

3 Comments

Don't store directory path in the database, store only file name. When outputting files, just prepend the directory which could be defined as a variable or a constant.
I agree, and was in the process of adding to my original response.
May thanks guys sortd it! Knew it had to be something simple like that.
0

I'm slightly confused by what you are asking, correct me if im wrong but this is what you have:

An upload system that uploads pictures to your image directory and adds imageName.jpg to your database. And you want to prefix 'images\' to each of the image names added to your database?

If thats the case, in your php script that the form triggers you should be able to set the image name as added to the db as 'image\.$imagename' assuming $imagename as the name of the image.

And if that does not work why not prefix it while accessing the img? print '<img src=image\"'.$imagename.'" /> Hope that helps.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.