Home > Archive > PHP Language > March 2004 > imagejpeg() error.
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
imagejpeg() error.
|
|
| Jason Cooke 2004-03-26, 11:13 pm |
| Can someone take a look at my code and tell me what I'm doing wrong. Thank
you so much.
Jason
----------------------------------------begin
code--------------------------------------------
//Check to see if an attachment was added, if so, copy it to the proper
directory.
$caption=addslashes($caption);
$path_to_upload_dir = "/home/sites/www.domain.com/web/images/inventory/";
if ($uploadedFile != "none"){
copy($uploadedFile, "$path_to_upload_dir/$file_name/$uploadedFile_name");
unlink($uploadedFile);
}
//Create thumbnail from large uploaded image.
$new_width=225; //Image width Change if needed
$new_height=225; //Image height Change if needed
$source_path="http://www.domain.com/images/inventory/"; //Source File path
$destination_path="http://www.domain.com/images/inventory/thumbs/";
//Destination file path
$image_name = $uploadedFile_name; //Image path retrived
global $source_path;
global $destination_path;
global $new_width;
global $new_height;
$destimg=imagecreate($new_width,$new_hei
ght) or die("Problem In Creating
image");
$srcimg=imagecreatefromjpeg($source_path
.$image_name) or die("Problem In
opening Source Image");
imagecopyresized($destimg,$srcimg,0,0,0,
0,$new_width,$new_height,ImageSX($sr
cimg),ImageSY($srcimg)) or die("Problem In resizing");
imagejpeg($destimg,$destination_path.$image_name) or die("Problem In
saving");
//Start the Insert record statement.
$linkID = mysql_connect("www.domain.com", "user", "pass"); //establish
connection to database
mysql_select_db("DB_Name", $linkID); //select database
$query=("insert into images (productID, productType, name, caption,
imgOrder) VALUES
('".$productID."','".$productType."','".$uploadedFile_name."','".$caption."'
,'".$imgOrder."')");//Build the query
$resultID = mysql_query($query, $linkID);
if ($resultID == TRUE) {
print ("The image was successfully added to the database.");
}
else {
print ("The image was <b>NOT</B> added to the database, please contact the
webmaster.");
echo mysql_error();
}
---------------------------------------end
code-----------------------------------------------
--------------------------------------begin
error------------------------------------------------
Warning: imagejpeg: unable to open
'http://www.domain.com/images/inventory/thumbs/quartz1.jpg' for writing in
/home/sites/site59/web/control/add/add_images_proc.php on line 81
Problem In saving
----------------------------------------end
error------------------------------------------------
| |
| John Smith 2004-03-26, 11:13 pm |
|
"Jason Cooke" <jc@jcimedia_JunK_.com> schreef in bericht
news:c3slso$4efk$1@news3.infoave.net...
> Can someone take a look at my code and tell me what I'm doing wrong. Thank
> you so much.
>
> Jason
>
> ----------------------------------------begin
> code--------------------------------------------
> //Check to see if an attachment was added, if so, copy it to the proper
> directory.
> $caption=addslashes($caption);
> $path_to_upload_dir = "/home/sites/www.domain.com/web/images/inventory/";
> if ($uploadedFile != "none"){
> copy($uploadedFile,
"$path_to_upload_dir/$file_name/$uploadedFile_name");
> unlink($uploadedFile);
> }
> //Create thumbnail from large uploaded image.
> $new_width=225; //Image width Change if needed
> $new_height=225; //Image height Change if needed
>
> $source_path="http://www.domain.com/images/inventory/"; //Source File
path
> $destination_path="http://www.domain.com/images/inventory/thumbs/";
> //Destination file path
>
> $image_name = $uploadedFile_name; //Image path retrived
>
> global $source_path;
> global $destination_path;
>
> global $new_width;
> global $new_height;
>
> $destimg=imagecreate($new_width,$new_hei
ght) or die("Problem In Creating
> image");
>
> $srcimg=imagecreatefromjpeg($source_path
.$image_name) or die("Problem In
> opening Source Image");
>
>
>
imagecopyresized($destimg,$srcimg,0,0,0,
0,$new_width,$new_height,ImageSX($sr[col
or=darkred]
> cimg),ImageSY($srcimg)) or die("Problem In resizing");
>
> imagejpeg($destimg,$destination_path.$image_name) or die("Problem In
> saving");
>
>
>
> //Start the Insert record statement.
> $linkID = mysql_connect("www.domain.com", "user", "pass"); //establish
> connection to database
> mysql_select_db("DB_Name", $linkID); //select database
>
> $query=("insert into images (productID, productType, name, caption,
> imgOrder) VALUES
>[/color]
('".$productID."','".$productType."','".$uploadedFile_name."','".$caption."'
> ,'".$imgOrder."')");//Build the query
> $resultID = mysql_query($query, $linkID);
> if ($resultID == TRUE) {
> print ("The image was successfully added to the database.");
> }
> else {
> print ("The image was <b>NOT</B> added to the database, please contact
the
> webmaster.");
> echo mysql_error();
> }
> ---------------------------------------end
> code-----------------------------------------------
>
>
> --------------------------------------begin
> error------------------------------------------------
> Warning: imagejpeg: unable to open
> 'http://www.domain.com/images/inventory/thumbs/quartz1.jpg' for writing in
> /home/sites/site59/web/control/add/add_images_proc.php on line 81
> Problem In saving
> ----------------------------------------end
> error------------------------------------------------
>
>
Do you have write permission in that directory?
And does PHP have those permission???
| |
| Jason Cooke 2004-03-26, 11:13 pm |
| I have set up both directories to have write permissions. I'm not sure about
php though, how do i check that. Shouldn't I be getting some sort of
permission denied error though?
"John Smith" <someone@nobody.com> wrote in message
news:c3sm2m$nco$1@news3.tilbu1.nb.home.nl...
>
> "Jason Cooke" <jc@jcimedia_JunK_.com> schreef in bericht
> news:c3slso$4efk$1@news3.infoave.net...
Thank
"/home/sites/www.domain.com/web/images/inventory/";[color=darkred]
> "$path_to_upload_dir/$file_name/$uploadedFile_name");
> path
Creating[color=darkred]
In[color=darkred]
>
imagecopyresized($destimg,$srcimg,0,0,0,
0,$new_width,$new_height,ImageSX($sr[col
or=darkred]
>
('".$productID."','".$productType."','".$uploadedFile_name."','".$caption."'
> the
in[color=darkred]
> Do you have write permission in that directory?
> And does PHP have those permission???
>
>
| |
| John Smith 2004-03-26, 11:13 pm |
|
"Jason Cooke" <jc@jcimedia_JunK_.com> schreef in bericht
news:c3sn5d$4flp$1@news3.infoave.net...
> I have set up both directories to have write permissions. I'm not sure
about
> php though, how do i check that. Shouldn't I be getting some sort of
> permission denied error though?
>
>
> "John Smith" <someone@nobody.com> wrote in message
> news:c3sm2m$nco$1@news3.tilbu1.nb.home.nl...
> Thank
proper[color=darkred]
> "/home/sites/www.domain.com/web/images/inventory/";
File[color=darkred]
> Creating
> In
>
imagecopyresized($destimg,$srcimg,0,0,0,
0,$new_width,$new_height,ImageSX($sr
//establish[color=darkred]
>
('".$productID."','".$productType."','".$uploadedFile_name."','".$caption."'
contact[color=darkred]
writing[color=darkred]
> in
>
>
Under Linux the dir should be world readable (I Think).
Chmod it to 777 and check if it works.
If so you should find out which 7 works for PHP (I think the last one).
But remeber this is a Major Security Flaw!!!
| |
| Jason Cooke 2004-03-26, 11:13 pm |
| yeah, their already set to 777. any other suggestions? anyone?
"John Smith" <someone@nobody.com> wrote in message
news:c3sp1j$v2k$1@news2.tilbu1.nb.home.nl...
>
> "Jason Cooke" <jc@jcimedia_JunK_.com> schreef in bericht
> news:c3sn5d$4flp$1@news3.infoave.net...
> about
> proper
> File
die("Problem[color=darkred]
>
imagecopyresized($destimg,$srcimg,0,0,0,
0,$new_width,$new_height,ImageSX($sr[col
or=darkred]
>
In
> //establish
>
('".$productID."','".$productType."','".$uploadedFile_name."','".$caption."'
> contact
> writing
> Under Linux the dir should be world readable (I Think).
> Chmod it to 777 and check if it works.
> If so you should find out which 7 works for PHP (I think the last one).
> But remeber this is a Major Security Flaw!!!
>
>
|
|
|
|
|