www.webdeveloper.com
+ Reply to Thread
Results 1 to 1 of 1
  1. #1
    Join Date
    Nov 2003
    Posts
    287

    uploading / resize problem

    Hi i'm working on a text editor for a CMS i have a fuction where you can upload an image and if it is uploaded the image is put into the text. This always worked great without resize but i want the images to be resized then saved and then put in the text. The script I'm using for this is:

    PHP Code:
        //change image size---------------------------------------------
        
    $image_type strstr($file_name'.');
        
    //SWITCHES THE IMAGE CREATE FUNCTION BASED ON FILE EXTENSION
            
    switch($image_type) {
                case 
    '.jpg':
                    
    $source imagecreatefromjpeg($file_name);
                    break;
                case 
    '.JPG':
                    
    $source imagecreatefromjpeg($file_name);
                    break;
                case 
    '.png':
                    
    $source imagecreatefrompng($file_name);
                    break;
                case 
    '.PNG':
                    
    $source imagecreatefrompng($file_name);
                    break;
                case 
    '.GIF':
                    
    $source imagecreatefromgif($file_name);
                    break;
                case 
    '.gif':
                    
    $source imagecreatefromgif($file_name);
                    break;
                }
        
    //
        
    list($width$height) = getimagesize($file_name);
        
    $propBigH        $height/$maxHeight;
        
    $propBigW        $width/$maxWidth;
        
    //
        
    if ($width $maxWidth){
            
    $heightBig         $height/$propBigW;
            
    $widthBig         $maxWidth;
        }
        else{
            
    $heightBig         $height;
            
    $widthBig         $width;
        }
        
    //
        
    $bigImg imagecreatetruecolor($widthBig$heightBig);
        
    imagecopyresized($bigImg$source0000$widthBig$heightBig$width$height);
        
        
        
    //---------------------------------------------------------------
        
    $result  =  imagejpeg($bigImg$file_path$qualityBig);
        if (!
    chmod($file_path,0755))
             
    $message "change permission to 755 failed.";
        else{
          echo 
    "<script language='JavaScript'>window.location.href = \"uploadOne.php?loaded='yes'&fileName='http://".$_SERVER['HTTP_HOST']."/CMS/img/files/".$file_name."'\";</script>";
                     
    "Something is wrong with uploading a file.";*/
         } 
    But this is not working, i think i'm forgetting something but i don't know what.. Can someone help me with this??

    I added the full script to this post as zip..
    Thanks in advance..
    Attached Files
    Zebdaag

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center



Recent Articles