PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Everything works fine. after clicking on image link you can download it. I use AcDsee to open images and i can preview the downloaded image, but the image seems to be corrupted when trying to open in another picture viewer. What i found out is that after downloading the image, the format of the file is changed. Originally the jpeg file is stored on server in ANSI format but after downloading it is stored in utf-8 format(still it is jpeg file). After changing format of the file back to ANSI in some editor(e.g notepad++) everything works fine. I played with headers a lot (changing content-type header, adding various charset values, even charset of my webpage etc) to no avail. Do you have any idea what is wrong? Thanks
It is important to filter user input. As your script is now, you are allowing users to download any file that is accessible to your script. This gives users access to the source code of your PHP files and other private data.
As for your formatting problem, you could try creating an image resource with imagecreatefromjpeg() or one of the other imagecreatefrom*() functions and output the image with imagejpeg().
Thank you for your reply. I will consider the security issue you commented on. As for the charset problem i figured it out. I have my images ready on the server in jpeg or png format so imagejpeg() or imagecreatefromjpeg() is not an option for me.
adding header('Content-Transfer-Encoding: binary') was not helpful either, nor was changing header('Content-type: image/jpeg') to header('Content-Type: application/octet-stream');
Script i provided in my previous post is stored in simple php file and this file had utf-8 format. I had to change it to ansi format and now everything works like a charm. Trivial enough but cost me time and nerves .