PDA

View Full Version : php images help...


grim918
January 2nd, 2006, 05:53 PM
im having a small problem with displaying images. when i use the <img> tag to display images, sometimes they wont load when i try to view the page.
i was wondering if images or the directory that they are in need to have permissions set so that the images will load. here is an example of something that i tried:

i created an images directory and i put a picture in there image_name.gif
then i created a copy of that same picture and put it in the same directory but i renamed the picture to 001.gif. here is how i did this

sudo cp /images/image_name.gif /images/001.gif

then i check to see if the picture is in the directory and yes it is.

i then create a simple html page to display the images.
<img src="/images/image_name.gif" />
<img src="/images/001.gif" />

this is where i run into a problem. image_name.gif will load and display on the browser but 001.gif will not load. does anyone know what is going on here

Neeko
January 2nd, 2006, 06:15 PM
Are the permissions the same on each file? The web server needs read permissions (I think). Open a term window and do:
ls -la and compare group permissions.

grim918
January 2nd, 2006, 06:23 PM
yes the read permissions on the files are the same. i chmod 644 the files so that they have read permissions. i just dont know why the copied picture wont load and the other one is ok. i get this problem with many other images that i try to display.

Neeko
January 2nd, 2006, 06:41 PM
Have you tried emptying your browser cache before loading the page?

grim918
January 3rd, 2006, 05:05 PM
how do i empty the browser cache before loading the page. i dont know how to do that.

Swab
January 3rd, 2006, 05:12 PM
how do i empty the browser cache before loading the page. i dont know how to do that.

If you are using firefox, click on the edit menu > preferences > privacy ... then click the clear cache button.

kperkins
January 3rd, 2006, 05:30 PM
try not using sudo to copy the file. If you use sudo to cp it, then root owns it, and not the user (you) who originally put it in the folder.
I just tried this and even sudo cp'ing I could see the both pics, so now I'm at a loss, myself. I can't figure what the problem could be, even though it does sound like a permissions issue. Of course I did this on my own comp, a webserver might not let you read files ownd by root if your not in the group.

Are you doing this on your own computer, or a web server? Is there an .htaccess file in the folder? That's all I've got.

grim918
January 3rd, 2006, 08:31 PM
i am in the /var/www/ directory so i cant copy a file in here unless i use sudo. unless there is another way of doing it that i dont know of. i am going to try the empty cache idea though. ill see how it goes. it really does sound like a permissions problem though. i cant find anything on the web on it though.

grim918
January 6th, 2006, 04:36 PM
i dont know what happend but i just left off this subject while i worked on other parts of my website. when i came back to it, it was working. i dont know what happend but im glad it now works. thanks for the help. problem solved.