 | 
August 16th, 2008, 09:55 AM
| | Newbie | | Join Date: Aug 2008
Posts: 7
| | error ouput opening a picture file
Hey guys,
I have created many picture files using gd_library, I recently decided to rename all of my pictures files on my web server to text instead of just numbers.
Example: productsssh.jpg
I am recently receiving a wierd error when I open up some of the picture files. Here is the name of the picture: productsssh.jpg.
I get the following error only when i open up that picture via the web: Quote:
Warning: Unexpected character in input: '' (ASCII=24) state=1 in /home/virtual/site1/fst/var/www/html/pics/productsssh.jpg on line 15
Warning: Unexpected character in input: ' in /home/virtual/site1/fst/var/www/html/pics/productsssh.jpg on line 15
Parse error: syntax error, unexpected T_STRING in /home/virtual/site1/fst/var/www/html/pics/productsssh.jpg on line 15
| When i rename the file to "producsssh.jpg" it opens up perfectly fine.
I don't know why i am getting an apache or php error when attempting to open the file. Second, I don't know why i am getting the error only when i try to view the file over the web via my server. If I actually download the file I can perfectly open it via my computer.
My webserver is a linux box redhat.
All I am doing is opening up a picture file via the web... why am i receinving a php or apache error.... where is the error coming from?
Any help regarding this matter would be greatly appriciated.
| 
August 16th, 2008, 03:06 PM
|  | Site Moderator | | Join Date: Apr 2007 Location: Texas Age: 24
Posts: 5,306
| |
Heya, Bytesc.
When you name your image file with a '.php' extension, Apache is trying to execute it as a PHP script, which is generating all those errors.
| 
August 16th, 2008, 09:53 PM
| | Newbie | | Join Date: Aug 2008
Posts: 7
| |
No the pictures are not witht he php extension. ALl the pictures are jpeg example: productssh.jpg.
| 
August 16th, 2008, 10:54 PM
|  | Moderator | | Join Date: Jun 2007 Location: York England :) Age: 18
Posts: 2,831
| | Quote: |
Originally Posted by bytesc No the pictures are not witht he php extension. ALl the pictures are jpeg example: productssh.jpg. | This isn't a PHP problem then.
I suggest you ask in the Apache forum.
| 
August 17th, 2008, 06:14 AM
|  | Moderator | | Join Date: Nov 2006 Location: Iceland Age: 22
Posts: 2,777
| | Quote: |
Originally Posted by bytesc No the pictures are not witht he php extension. ALl the pictures are jpeg example: productssh.jpg. | Given the warnings it is showing you, it looks like your HTTP server is trying to execute the images as PHP code, which is highly unusual unless you have been messing around with the server's configuration.
Have you been doing anything like that?
Are your images being called via some PHP code, or simply being fetched the old fashion way, via a public URL?
| 
August 17th, 2008, 06:27 AM
| | Newbie | | Join Date: Aug 2008
Posts: 7
| |
I haven't played around with any of my settings and no I am simply calling up the pictures by directly, example:
http://www.site.com/pics/pictures.jpg
Maybe somehow, apache is reading the jpg files as php which is very strange and does not happen when my pictures are in number name format. example 112233.jpg
By the way this only happens to pictures that i have created with php gd library, via php.
This is very strange, I am really confused!
| 
August 17th, 2008, 07:15 AM
|  | Moderator | | Join Date: Nov 2006 Location: Iceland Age: 22
Posts: 2,777
| |
Ok.
That is strange. Your HTTP server should not be executing that as PHP code, unless it is told to do so.
The name of the file shouldn't make a difference. Whether they are alpha-numeric or strictly a numeric string, it shouldn't have any effect on how the server handles them.
Seeing as this is only happening to PHP generated images, I would guess the problem is there.
Could you show us the code that you used to create them?
| 
August 17th, 2008, 09:02 AM
| | Newbie | | Join Date: Aug 2008
Posts: 7
| |
Here is the code I have used to create the picture:
[PHP]
$i = http://www.site.com/pic1.jpg
$ni = "/home/virtual/site1/var/www/html/pics/new_pic.jpg";
if (!$img=@imagecreatefromjpeg("$i")) {
die;
}
$newimg=imagecreatetruecolor(100,100);
$bgColor = imagecolorallocate($newimg, 255,255,255);
imagefill($newimg,0,0,$bgColor);
imagecopyresampled($newimg,$img,0,0,0,0,100,100,10 0,100);
imagejpeg($newimg, $ni);
[/PHP]
The thing is I have been using this code for almost 1 year and never had a single error like the one I am facing now. As soon as I decided to name the file text names the error starting happening.
By the way thanking for taking the time to help me debug this issue.
| 
August 17th, 2008, 10:21 PM
|  | Moderator | | Join Date: Nov 2006 Location: Iceland Age: 22
Posts: 2,777
| |
Ok. I can't see why that would cause problems. Seems perfectly fine to me.
Which brings us back to your HTTP server.
Do you have use any .htaccess files in your site?
Could this be some url_rewrite fluke?
I've heard of instances where JPEG images have been used to execute malicious code on a PHP server.
I guess that would be technically possible if somebody managed to alter your image and mess with your .htaccess files.
Could that be a possibility?
Have you tried copying the images to a different server to see if it works there?
If this is a configuration error or a bug in your Apache installation, re-installing it or upgrading may help.
| 
August 18th, 2008, 05:59 AM
| | Newbie | | Join Date: Aug 2008
Posts: 7
| |
The pictures are not uploaded, but downloaded by us.
I have uploaded the picture to a different server of mine and it works perfectly. I don't know why i am getting this error only with my older server and why now... this is very strange. Is there a place to check for file assossications in apache?
Thanks
| 
August 18th, 2008, 02:57 PM
|  | Site Moderator | | Join Date: Apr 2007 Location: Texas Age: 24
Posts: 5,306
| |
How do you display the images? Are you using a PHP proxy page, or do you drop the URL into an img tag?
If the only difference between the files that work and the files that don't is that one has numbers in the name and the other has letters (but the extension doesn't change), the only idea that jumps out at me (as Atli suggested, credit where credit's due) is that these images are now triggering some kind of mod_rewrite rule.
| 
August 18th, 2008, 02:59 PM
|  | Site Moderator | | Join Date: Apr 2007 Location: Texas Age: 24
Posts: 5,306
| |
I'm going to go ahead and move this thread to the Apache forum and see what else we can come up with.
| 
August 18th, 2008, 10:34 PM
| | Newbie | | Join Date: Aug 2008
Posts: 7
| |
I understand that a mod rewrite might be the issue, but I have set none and how would I go about tackling this issue?
Thanks,
| 
August 18th, 2008, 11:41 PM
|  | Moderator | | Join Date: Nov 2006 Location: Iceland Age: 22
Posts: 2,777
| |
Search for .htaccess files in your file-structure, all the way from the web-root to the directory that contains the image.
A .htaccess file can define any number of things that could be causing problems.
You should also look through the httpd.conf file. See if you can find anything relating to images.
Not sure exactly where redhat puts that file, but a good place to start looking is /etc/apache2
|  |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | | | What is Bytes?
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over network members.
|