Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

imagejpeg() error.
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------------------------------------------------



Report this thread to moderator Post Follow-up to this message
Old Post
Jason Cooke
03-27-04 04:13 AM


Re: imagejpeg() error.
"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???



Report this thread to moderator Post Follow-up to this message
Old Post
John Smith
03-27-04 04:13 AM


Re: imagejpeg() error.
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/"; 
> "$path_to_upload_dir/$file_name/$uploadedFile_name"); 
> path 
Creating 
In 
>
 imagecopyresized($destimg,$srcimg,0,0,0,
 0,$new_width,$new_height,ImageSX($sr[col
or=darkred]
 
>
('".$productID."','".$productType."','".$uploadedFile_name."','".$caption."'
 
> the 
in 
> Do you have write permission in that directory?
> And does PHP have those permission???
>
>



Report this thread to moderator Post Follow-up to this message
Old Post
Jason Cooke
03-27-04 04:13 AM


Re: imagejpeg() error.
"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 
> "/home/sites/www.domain.com/web/images/inventory/"; 
File 
> Creating 
> In 
>
 imagecopyresized($destimg,$srcimg,0,0,0,
0,$new_width,$new_height,ImageSX($sr
 
//establish 
>
('".$productID."','".$productType."','".$uploadedFile_name."','".$caption."'
 
contact 
writing
> 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!!!



Report this thread to moderator Post Follow-up to this message
Old Post
John Smith
03-27-04 04:13 AM


Re: imagejpeg() error.
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 
>
 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!!!
>
>



Report this thread to moderator Post Follow-up to this message
Old Post
Jason Cooke
03-27-04 04:13 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PHP Language archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 02:40 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.