Well.. you can't have
this thingy in your file because of this:Code:<table border="1"> <tr> <td><? echo $id; ?></td> <td><img src="showimage.php?id=<?=$id;?>" width="144" height="165" /></td> <td><? echo $imagename; ?></td> <td><? echo $description;?></td> </tr>
this thingy tells to browser that your file is a jpeg image file.. and have you seen a picture with html in it ?Code:header('Content-type: image/jpeg');
I believe no.. so just remove this html..and you will be fine![]()
Thank you very much, this is a very good tutorial
Wouldnt it be better - instead of doing the "addslash" and just echoing it out directly to just do some type of encryption/decryption? The one I always used was "base64_encode" and "base64_decode". Either way nice tutorial I really enjoyed it.
cheers for the tutorial
code works perfectly in Firefox
however when using Safari (and working on an apple mac) instead of showing the image it simply downloads the php file that should be displaying the image.
is there some simple code I can add to solve this, or is this something that Safari does and I need new/different code to ensure compatibility with all browsers?
Hi I have followed all the steps and I understand the concept behind uploading and displaying an image, however the image still does not display for me.
I believe the problem is with the rights of the file or something. The reason why I think so is because i have tried uploading an image to the "uploads" folder with ftp and i can easily display it however if i upload the same exact image with the upload form and then i try to view it I get the following message "403 Forbidden".
If it makes any difference I am using a hosted site.
Any idea why when i upload an image with the upload form it becomes forbidden in the folder?
Well.. Here we upload a picture into a database and then you are displaying it.. it must work correctly.. but if you upload your picture to a folder and you have this error then I believe there are problems with folder viewing permissions.. do you have a .htaccess file there or something ?
So I have the following setup:
mywebsite.com contains a folder "uploads"
mywebsite.com contains all of my php pages
I host my website, so in order to make sure that my folder(uploads) had read and write access rights i have created it on my computer and then sent it with ftp to my host. So I assume the folder still has the correct permission rights set up.
I am not sure what .httaccess you are referring to. But the "uploads" folder contains nothing but the images i try uploading.
It is weird that it works fine if i ftp and image (i am then able to view it). But if i use the uploads form it does get uploaded but i cant view it and get that "forbidden" message.
Thank you for help!
Well.. check the folder's permissions.. is it 0777 or just 777 or something else ?
I called up the website i am hosting with and was told that
the folder has correct permission settings but the image files do not have correct permission settings. It seems that the permission settings of the image file change when it is uploaded through the file upload form.
I was told that i need to change permission setting in my actual code. any idea how to do so?
you can use this function PHP: chmod - Manual
like this:
Code:chmod("path/to/your/file.jpg", 0777);
There are currently 2 users browsing this thread. (0 members and 2 guests)
Bookmarks