473,387 Members | 1,549 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

error ouput opening a picture file

7
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:


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.
Aug 16 '08 #1
13 2963
pbmods
5,821 Expert 4TB
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.
Aug 16 '08 #2
bytesc
7
No the pictures are not witht he php extension. ALl the pictures are jpeg example: productssh.jpg.
Aug 16 '08 #3
Markus
6,050 Expert 4TB
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.
Aug 16 '08 #4
Atli
5,058 Expert 4TB
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?
Aug 17 '08 #5
bytesc
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!
Aug 17 '08 #6
Atli
5,058 Expert 4TB
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?
Aug 17 '08 #7
bytesc
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.
Aug 17 '08 #8
Atli
5,058 Expert 4TB
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.
Aug 17 '08 #9
bytesc
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
Aug 18 '08 #10
pbmods
5,821 Expert 4TB
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.
Aug 18 '08 #11
pbmods
5,821 Expert 4TB
I'm going to go ahead and move this thread to the Apache forum and see what else we can come up with.
Aug 18 '08 #12
bytesc
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,
Aug 18 '08 #13
Atli
5,058 Expert 4TB
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
Aug 18 '08 #14

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Hari Prasad | last post by:
Hi, I have downloaded some image files by connecting to a URL and I am trying open that image file using BrowserLauncher. I am using windows xp and the default one to open image files is windows...
7
by: mattsniderppl | last post by:
Hi, i'm relatively new to C++ from java and am having a difficult time with pointers. I'm sure there is something simple that I am doing wrong, but I can't seem to write this in a way that doesn't...
14
by: D. Alvarado | last post by:
Hello, I am trying to open a window containing an image and I would like the image to be flush against the window -- i.e. have no padding or border. Can I make this happen with a single call to a...
11
by: Shane Suebsahakarn | last post by:
Hi all, This might be one of those things for which there is no workaround. I'm using A2K2, and using it to perform a very large batch ouput. Both the front and back ends are MDB files, so no...
13
by: lgbjr | last post by:
Hello All, I have some pictureboxes on a VB.NET form that are linked to an AccessDB. If the user wishes to open or edit an image, I need to save the image in the picturebox to a temp file, then...
12
by: Lance | last post by:
hey all, first time vb.net 2005 user, after sticking vb6 out for a long time... anyway, using this code ====================== Dim FS As FileStream = File.OpenRead(Filename) Dim theImage As...
1
by: Tim Marshall | last post by:
In my not too successful attempts to get an OLE chart object (Graph 11.0) that has been manipulated on a form to be reproduced on a report, I am considering the following procedure. First copy the...
0
by: Johnny Jörgensen | last post by:
I'm currently doing an application in VB.NET 2005 where I need the possiblity to perform certain file tasks: 1) I've got a HTML page open in a WebBrowser control. I want the user to be...
0
by: bytesc | last post by:
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 ...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.