Hi all,
I have a script to built thumbnails for some images.
It's working great, but when the file name for the original picture contains a single quote, it skips that picture.
I use this:
imagejpeg($result, "thumb/".$title.".jpg", 100) or die("Cant save image");

$title is the picture name, received direct from a database.

So a picture named "Dani PHP.jpg" will go fine, but a picture named "Dani's PHP.jpg" will not.

Well, if the imagejpeg() function is chocking on the apostrophe, all you need to do is remove the offending character from $title:

imagejpeg($result, "thumb/" . str_replace("'","",$title) . ".jpg", 100) or die("Cant save image");

But I want to have the single quote in the picture name.. I don't want to remove it... Is it possible?

try the following, if it still doesn't work, then the problem is the imagejpeg() function in which case you'll have not choice but to remove it.

imagejpeg($result, "thumb/" . stripslashes($title) . ".jpg", 100) or die("Can't save image");

I already tried stripslashes().. Maybe I should remove the single quotes :(
Thanks for helping guys!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.