hello

I'm using the following function from the php manual (user's posts) and get
the following error.

What I do is upload a file from the user and save it in the server; that's
working fine; what I want is to save a copy of the file in thumbnail size.


-----------------------------------------------------------------------------------------------------
function resampimagejpg($forcedwidth, $forcedheight, $sourcefile, $destfile,$imgcomp)
   {
   $g_imgcomp=100-$imgcomp;
   $g_srcfile=$sourcefile;
   $g_dstfile=$destfile;
   $g_fw=$forcedwidth;
   $g_fh=$forcedheight;

   if(file_exists($g_srcfile))
       {
       $g_is=getimagesize($g_srcfile);
       if(($g_is[0]-$g_fw)>=($g_is[1]-$g_fh))
           {
           $g_iw=$g_fw;
           $g_ih=($g_fw/$g_is[0])*$g_is[1];
           }
           else
           {
           $g_ih=$g_fh;
           $g_iw=($g_ih/$g_is[1])*$g_is[0];
           }
       $img_src=imagecreatefromjpeg($g_srcfile);
       $img_dst=imagecreate($g_iw,$g_ih);

       imagecopyresampled($img_dst, $img_src, 0, 0, 0, 0, $g_iw, $g_ih,$g_is[0], 
$g_is[1]);
       imagejpeg($img_dst, $g_dstfile, $g_imgcomp);
       imagedestroy($img_dst);
       return true;
       }
       else
       return false;
   }
----------------------------------------------------------------------------------------------------------
** This is where I call the function:

  $archivo = $forma['imagen']['tmp_name'];
  echo("<b>File Uploaded Information:</b> <br>" . $archivo . "<br>");

  if(is_uploaded_file($archivo)) {
   $directo = "/home/public_html/img_products/";
   $archivito = $directo . $forma['imagen']['name'];

   $archivote = "/home/public_html/img_small_products/" .
$forma['imagen']['name'];  //

   echo "<br>" . $archivito . "<hr>";
            move_uploaded_file($forma['imagen']['tmp_name'],$archivito) ;

               resampimagejpg(100, 100, $archivito, $archivote, 0);    
<<<================= Here I call the function

--------------------------------------------------------------------------------------------------------------

This is the error I get:

Warning: imagejpeg(): Unable to open '/home/public_html/img_small_products/A2_6.jpg' 
for writing in /home/public_html/admin/products.php on line 286

any idea? Thanks!

max

Reply via email to