473,320 Members | 2,177 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,320 software developers and data experts.

ImageCreateFromJPEG fails if path contains apostrophe ?

hi there,

i am experiencing a strange problem. i am iterating through a given
directory, selecting only jpg - images that are then resized and
inserted into a database. everything works, but if there is a file
with an apostrophe in it the GD function @ImageCreateFromJPEG fails.
anyone knows this problem and possible workarounds?

thank you,
tim

here is the code
[list.php]
....
while ( $file = readdir($dirhandle) )
{
echo "
....
<a href="show_image.php?path='.rawurlencode($dir.'/'.$file).'">show</
a><br />
....
";
}
....

[show_image.php]
....
if ( $image = LoadJpeg(rawurldecode($_GET["path"])))
{
header("content-type:image/jpeg");
imagejpeg($image);
}
....

with function LoadJpeg defined as:

//taken from http://www.hpserver.de/php/function....efromjpeg.html
function LoadJpeg ($imgname) {
$im = @ImageCreateFromJPEG ($imgname); /* Versuch, Datei zu öffnen
*/
if (!$im) { /* Prüfen, ob fehlgeschlagen
*/
$im = ImageCreate (150, 30); /* Erzeugen eines leeren
Bildes */
$bgc = ImageColorAllocate ($im, 255, 255, 255);
$tc = ImageColorAllocate ($im, 0, 0, 0);
ImageFilledRectangle ($im, 0, 0, 150, 30, $bgc);
/* Ausgabe einer Fehlermeldung */
ImageString($im, 1, 5, 5, "Fehler beim Öffnen von: $imgname",
$tc);
}
return $im;
}

Feb 27 '07 #1
1 2923
ti**********@googlemail.com wrote:
if there is a file
with an apostrophe in it the GD function @ImageCreateFromJPEG fails.
anyone knows this problem and possible workarounds?
Since you are passing the path of the file using GET variables, you may
be a victim of "magic quotes". See:
http://www.php.net/manual/en/ref.inf...gic-quotes-gpc
http://www.php.net/manual/en/function.stripslashes.php

To be sure, echo the filename and see if it is correct.
Feb 27 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: jn | last post by:
I'm working with images from a Kodak 2MP camera. It looks like the function will only create a resource if I give it horiznotal pictures from this camera....if I give it vertical (height larger...
4
by: Mike | last post by:
hopefully this is an easy one to solve and I'm just missing something little... basically, I had a nice little website running with php, apache, etc... that uses imagecreatefromjpeg to create...
2
by: jn | last post by:
This is the weirdest thing I've come across in a while. I'm trying to resize an image. If I give it a small image ( < 100K) it will resize. If I give it a larger image, it gives me the IE "Action...
4
by: Joseph | last post by:
Hi, I've got a page which updates a record, but it fails if the text used contains an apostrophe. I understand I need to replace apostrophes with double quotes in order for it to work? I also...
1
by: Michael | last post by:
Hallo, for some reasons of calling functions with parameters, i have to test if a text-node contains an apostrophe. My problem is that i cannot write something like <xsl:if test="contains(.,...
1
by: Rose | last post by:
Hi all, I'm trying to create a clickable link, but the pesky apostrophe is preventing the link from getting displayed properly. I'm displaying the contents of a folder (with contains the...
5
by: Areric | last post by:
Ok all. I have a series of images stored in a db. Im trying to work on a script that will let me scale them based on user input. Ive hit a bit of a roadblock on this line. $orig =...
2
by: Greg | last post by:
I have a bizarre situation in which serialisation is failing routinely under a specific condition, and I'm wondering if the details ring a bell with anyone here. I have 2 classes that my...
13
by: titan nyquist | last post by:
How do you test a string to see if it contains special characters? I want to ensure that any names typed into my form has only letters (and maybe allow a dash and an apostrophe). I can loop...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.