473,609 Members | 1,943 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ImageCreateFrom JPEG 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 @ImageCreateFro mJPEG fails.
anyone knows this problem and possible workarounds?

thank you,
tim

here is the code
[list.php]
....
while ( $file = readdir($dirhan dle) )
{
echo "
....
<a href="show_imag e.php?path='.ra wurlencode($dir .'/'.$file).'">sho w</
a><br />
....
";
}
....

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

with function LoadJpeg defined as:

//taken from http://www.hpserver.de/php/function....efromjpeg.html
function LoadJpeg ($imgname) {
$im = @ImageCreateFro mJPEG ($imgname); /* Versuch, Datei zu öffnen
*/
if (!$im) { /* Prüfen, ob fehlgeschlagen
*/
$im = ImageCreate (150, 30); /* Erzeugen eines leeren
Bildes */
$bgc = ImageColorAlloc ate ($im, 255, 255, 255);
$tc = ImageColorAlloc ate ($im, 0, 0, 0);
ImageFilledRect angle ($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 2941
ti**********@go oglemail.com wrote:
if there is a file
with an apostrophe in it the GD function @ImageCreateFro mJPEG 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
2241
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 than width) images, it fails to create a resource. What the hell is it doing?
4
21607
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 thumbnails of larger pictures. recently, I upgraded my system from suse 8.2 to suse 9.0, so I assume my php/apache rpms were upgraded in the process...
2
3999
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 Cancelled" page. The memory_limit for PHP has been changed to 30MB so that's not the problem. I know that the line with imagecreatefromjpeg() is the problem (even though I can't get an error message). I can run this code with the large images...
4
6210
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 know there's a piece of code which can be used to do this, and replace all apostrophes so that it works. Any help would be greatly appreciated!
1
1840
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(., ''')">. So i tried using entities or escaping, like that: <xsl:if test="contains(., '&apos;')"> or: <xsl:if test="contains(., '\'')"> but both didn't work.
1
4020
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 apostrophe), with the filename as a clickable link. The files show up properly, but the link location cuts off at the apostrophe. Here's a code snippet (fi is an instance of FileInfo):
5
3337
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 = imagecreatefromjpeg("DisplayImage.php?imageId=".$this->mImage->GetImageId()); Specifically it cant sopen that file. DisplayImage.php is pretty simple, it just displays an image from the
2
1325
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 application serialises before closing down. One of these classes contains a string field which contains a path to a file. This is populated from the contents of a text box, which in turn is populated using an OpenFileFialog object. Under normal usage,...
13
20738
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 RealName.Contains("..."), but there must be a more elegant solution.
0
8095
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8588
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8556
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8410
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7030
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6068
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4037
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2541
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1690
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.