Jump to content
Larry Ullman's Book Forums

Calling Uploaded Files Into For Loops In Tables


Recommended Posts

Okay. The issue is definitely with the paths being all screwy. I apologize, but I didn't realize you were using XAMPP. I wish you had stated that before.

 

With that said, is it safe to assume that htdocs in the XAMPP folder is set to your localhost? If so, let's imagine the following:

 

htdocs/localhost

|

|--view_images (folder)

|

|--img (folder)

| |

| |--image1.jpg

|

|--index.html

 

If that's your file structure, that an image would be loaded from index.html as follows:

 

<img src="img/image1.jpg">

 

The following is also okay (and my preferred method):

 

<img src="./img/image1.jpg">

 

Anyway, I apologize if this is all too elementary, but the point is, put everything in the htdocs folder, and make sure the paths are relative to the script referencing the images. Make sure all your paths are working and you can properly load images manually before making SQL queries to do it for you automatically.

Link to comment
Share on other sites

even using the file inside the htdocs it still doesn't show the image I put the alt="' . $row['column'] . '" in the img tag and it will show the information from the row but not the picture

 

the picture is stored in XAMPP/htdocs/upload/userid

 

and still doing the same thing when I right click on the icon on the browser and hit properties it shows

2.jpg

Protocol: Not Available

Type: Not Available

Address(URL): Not Available

Size: Not Available

Dimensions: 75 x 75 pixels

Link to comment
Share on other sites

somehow its not getting all the information it needs out of the file which is intact in its original state I didn't change anything of it this time in the code I just took its information and put into the uploads table in the database just for reference. so if I take the name the type and the size and put that into the database table for uploads can I take that information and make a temporary file inside the htdocs then use that file as the img src? I know larry uses urlencode when sending the file to a new window but I need to display in same window inside an html table row where the image is going to change for everyrow.

Link to comment
Share on other sites

Two posts ago, you said you placed the info in the alt attribute. That's not going to display the image. The alt attribute is designed to explain what the image is in the event that the image cannot actually be displayed.

 

You need to use the src attribute.

 

If you could please give specifics, what is the EXACT relationship between the script referencing the image and the image itself (i.e., where are they relative to each other)? And what is the exact path you are pulling from the DB to load the image?

 

Thank you.

Link to comment
Share on other sites

I used to alt attr to see if it was getting the info, but I figured it out and I'm kicking my ass for it I was using the directory path and not localhost/path so now it is working just won't let me add files using move_uploaded_file using http so that function keeps the full directory path like d:/xampp/htdocs/upload/userid

Link to comment
Share on other sites

Yeah if I run http://localhost/ in my browser it will load any page named index in there I could of set the directory wrong for the $dir token but using http://localhost/upload worked I didn't try it your way yet using ('./uploads') but I think it's because the script I'm working on is in a folder inside the htdocs folder and some reason I can only go back 1 folder in php ../../ doesn't work for going back more folders

Link to comment
Share on other sites

I actually don't know the details for XAMPP, but you may not be able to reference files outside of the htdocs folder. Next time I use XAMPP, I will test it out. I would just assume that you can't though, and keep the images in the htdocs folder for now. You can always easily change the path at a later time for the live site. Just make sure that you get everything working first, and then worry about the path later.

Link to comment
Share on other sites

 Share

×
×
  • Create New...