how can i creat thumbnail images for the image file that i upload using phpfileuploader ?

Last post 10-27-2010, 2:38 PM by Adam. 1 replies.
Sort Posts: Previous Next
  •  10-26-2010, 11:26 PM 64717

    how can i creat thumbnail images for the image file that i upload using phpfileuploader ?

    how can i creat thumbnail images for the image file that i upload using phpfileuploader ?
    Filed under:
  •  10-27-2010, 2:38 PM 64737 in reply to 64717

    Re: how can i creat thumbnail images for the image file that i upload using phpfileuploader ?

    Please try the following code:
     
    <?php require_once "phpuploader/include_phpuploader.php" ?>
    <?php session_start(); ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
     <title>
    Thumbnail Example
     </title>
    </head>
    <body>
     
       <form id="form1" method="POST">
        <?php    
         $uploader=new PhpUploader();
         $uploader->MaxSizeKB=10240;
         $uploader->Name="myuploader";
         $uploader->InsertText="Select multiple files (Max 10M)";
         $uploader->AllowedFileExtensions="*.jpg,*.png,*.gif"; 
         $uploader->MultipleFilesUpload=true;
         $uploader->Render();
         
       function PhpGallery_Impl_LoadImage($imagefile)
        {
                 $ext=pathinfo($imagefile,PATHINFO_EXTENSION);
                 switch(strtolower($ext))
                 {
                    case "png":
                       return imagecreatefrompng($imagefile);
                    case "gif":
                       return imagecreatefromgif($imagefile);
                    case "jpg":
                    case "jpeg":
                    default:
                       return imagecreatefromjpeg($imagefile);
                 }
         }
         
      function PhpGallery_GenerateThumbnail($imagefile,$thumbpath,$width,$height)
      {
             $img=PhpGallery_Impl_LoadImage($imagefile);
             $thumb=imagecreatetruecolor($width,$height);
             imagecopyresized($thumb,$img,0,0,0,0,$width,$height,imagesx($img),imagesy($img));
             imagejpeg($thumb,$thumbpath);
             imagedestroy($img);
             imagedestroy($thumb);
      }
          ?>
     </form>
       
      
    <?php
    $fileguidlist=@$_POST["myuploader"];
    if($fileguidlist)
    {
    $guidlist=split("/",$fileguidlist);    
    $path="D:/2005/test/Photos/";
        foreach($guidlist as $fileguid)   
        {   
       
            $mvcfile=$uploader->GetUploadedFile($fileguid);      
            if($mvcfile)      
            {      
            $mvcfile->MoveTo($path.$mvcfile->FileName);
            PhpGallery_GenerateThumbnail($path.$mvcfile->FileName,$path."thumbnail".$mvcfile->FileName,128,128);
            }   
        }   
        }
    ?>
        
     </div>
    </body>
    </html>

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

View as RSS news feed in XML