![]() |
How to display image from a database
i have a script i wrote that uploads an image to the database then moves it to a directory leaving only image path in the database but when i try to display the image i does not show any help appreciated. Thanks
Upload script PHP Code:
PHP Code:
|
Please tell me, what path is saved in your database?
|
I just want to clarify something here.. from this code you're storing the image path to a file on the disk yet in your previous topic you state that you are using a blob and can see the blob size? :confused: Which is it and did you amend the data if you've restructured your columns? - I only ask because if picture is still containing blobs and you're rying to print file paths..
|
Quote:
Sorry i am just a bit confused i only see BLOB and a size in the database. Does that mean their is nothing stored. |
Right so if you're seeing a blob then you have a field that is taking blob data.
What are you putting into it - from the code you've shown above, it looks like you're storing the filename and path yet from the code in your previous topic you were storing the file itself in the blob field. Which is it? |
Quote:
|
Ok so you need to test the file path to the image then. You're not far from it, you've got it printing the file path into your html so now you just need to figure out whats wrong with the final path in the html.
You can copy it out and add it onto the url in the browser bar - thats one way of testing it. |
Quote:
Thanks for your help so far here is a link to my site: http://speedycarloans.ca/testimonials/ Right now it only display the default image because i used an if statement to check if the database is empty or not. |
Quote:
|
I wouldn't store the path to the image in the database, just the file name - with or without the ext. Ex: ny-city-9456.jpg or ny-city-9456
The image path should be in the while loop that queries the database. ---- |
Quote:
|
Quote:
The MySQL data type should be something like VARCHAR or TINYTEXT maybe 30 characters for an image file name. You don't need BLOB. --- |
Quote:
You posted another topic today. In that code you were putting the actual file inside the database. Since then you've decided to use the filename / path. When you change your mind and decide to use the filename instead of the file stream, you must delete the old files that are stored in the database and change the column from a blob to a text field instead. I suspect the reason none of your images are showing is because instead of printing a file name and path in your html, you're trying to print a filestream instead. |
Quote:
i changed the type to varchar with a length of 255 characters but till no image. this is what i have for my output code now PHP Code:
|
Quote:
--- |
| All times are GMT +1. The time now is 10:54 PM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.