upload mit thumbs erstellen

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • upload mit thumbs erstellen

    ich habe mir ein script gebastelt was einen upload macht und thumbs erstellt!

    aber ich hab irgendwo einen fehler! er erstellt mir nix!

    PHP-Code:
    include ("dbconnect.php");
    $imgname $_FILES['userfile']['name'];
    $path 'upload';

    $sub substr($imgname, -4);

    if ((
    $sub == ".jpg") || ($sub == "JPEG") || ($sub == ".JPG") || ($sub == "jpeg") || 
    (
    $sub == ".gif") || ($sub == ".GIF")|| ($sub == ".png") || ($sub == ".PNG")){

      
    $folder_scr  "upload";
      
    $des_src     "thumbs";
      
    $thumbx      "70";
      
    $thumby      "70";
      
    //thumbs create
      
    function mkthumb($img_src,    
                       
    $img_width,   
                       
    $img_height
                       
    $folder_scr,  
                       
    $des_src)  
      {

        if ((
    $sub == ".jpg") || ($sub == "JPEG") || ($sub == ".JPG") || ($sub == "jpeg")){   
      
        
    $image imagecreatefromjpeg($folder_scr."/".$img_src);
        list(
    $src_width$src_height) = getimagesize($folder_scr."/".$img_src);
                if(
    $src_width >= $src_height)
                {
                
    $new_image_width $img_width;
                
    $new_image_height $src_height $img_width $src_width;
                }
                    if(
    $src_width $src_height)
                    {
                      
    $new_image_height $img_width;
                       
    $new_image_width $src_width $img_height $src_height;
                    }
        
    $new_image imagecreatetruecolor($new_image_width$new_image_height);
        
    imagecopyresampled($new_image$image0000$new_image_width,$new_image_height$src_width$src_height);
        
    imagejpeg($new_image$des_src."/".$img_src100);
        }
                if ((
    $sub == ".gif") || ($sub == ".GIF")){   
      
                   
    $image imagecreatefromgif($folder_scr."/".$img_src);
                   list(
    $src_width$src_height) = getimagesize($folder_scr."/".$img_src);
                           if(
    $src_width >= $src_height)
                           {
                           
    $new_image_width $img_width;
                          
    $new_image_height $src_height $img_width $src_width;
                        }
                            if(
    $src_width $src_height)
                            {
                              
    $new_image_height $img_width;
                              
    $new_image_width $src_width $img_height $src_height;
                            }
                
    $new_image imagecreatetruecolor($new_image_width$new_image_height);
                
    imagecopyresampled($new_image$image0000$new_image_width,$new_image_height$src_width$src_height);
                
    imagegif($new_image$des_src."/".$img_src100);
                  }            
                
                        if ((
    $sub == ".png") || ($sub == ".PNG")){   
      
                        
    $image imagecreatefrompng($folder_scr."/".$img_src);
                        list(
    $src_width$src_height) = getimagesize($folder_scr."/".$img_src);
                                if(
    $src_width >= $src_height)
                                {
                                  
    $new_image_width $img_width;
                                  
    $new_image_height $src_height $img_width $src_width;
                                }
                                        if(
    $src_width $src_height)
                                        {
                                        
    $new_image_height $img_width;
                                          
    $new_image_width $src_width $img_height $src_height;
                                        }
                         
    $new_image imagecreatetruecolor($new_image_width$new_image_height);
                        
    imagecopyresampled($new_image$image0000$new_image_width,$new_image_height$src_width$src_height);
                        
    imagepng($new_image$des_src."/".$img_src100);
                        }
      }
    // ende funktion

      
    $filename $_SERVER['PHP_SELF'];
      
    $verz=opendir($folder_scr);
      
    $linkl = array ();
          while (
    $file readdir ($verz))
          {
            if(
    $file != "." && $file != ".." && $file != $filename)
            {
            
    array_push ($linkl"$file"); 
            }
        }
      
              
    $anzahl count($linkl);
              
    sort ($linkl);
              foreach(
    $linkl as $key => $value)
              {
                if(!
    file_exists($des_src."/".$value))
                {
                  
    mkthumb($value$thumbx$thumby$folder_scr$des_src);
                }
              }
              
    closedir($verz);
     
      
    $folder_scr  "upload";
      
    $des_src     "view";
      
    $thumbx      "240";
      
    $thumby      "240";
      
    //viewpicture create
      
    function view($img_src,    
                    
    $img_width,   
                    
    $img_height
                    
    $folder_scr,  
                    
    $des_src)     
      {
        if ((
    $sub == ".jpg") || ($sub == "JPEG") || ($sub == ".JPG") || ($sub == "jpeg")){   
      
        
    $image imagecreatefromjpeg($folder_scr."/".$img_src);
        list(
    $src_width$src_height) = getimagesize($folder_scr."/".$img_src);
            if(
    $src_width >= $src_height)
            {
            
    $new_image_width $img_width;
            
    $new_image_height $src_height $img_width $src_width;
            }
                   if(
    $src_width $src_height)
                {
                
    $new_image_height $img_width;
                
    $new_image_width $src_width $img_height $src_height;
                }
        
    $new_image imagecreatetruecolor($new_image_width$new_image_height);
        
    imagecopyresampled($new_image$image0000$new_image_width,$new_image_height$src_width$src_height);
           
    imagejpeg($new_image$des_src."/".$img_src100);
          }
      
            if ((
    $sub == ".gif") || ($sub == ".GIF")){   
      
            
    $image imagecreatefromgif($folder_scr."/".$img_src);
            list(
    $src_width$src_height) = getimagesize($folder_scr."/".$img_src);
                    if(
    $src_width >= $src_height)
                    {
                      
    $new_image_width $img_width;
                      
    $new_image_height $src_height $img_width $src_width;
                    }
                        if(
    $src_width $src_height)
                        {
                          
    $new_image_height $img_width;
                          
    $new_image_width $src_width $img_height $src_height;
                        }
            
    $new_image imagecreatetruecolor($new_image_width$new_image_height);
            
    imagecopyresampled($new_image$image0000$new_image_width,$new_image_height$src_width$src_height);
            
    imagegif($new_image$des_src."/".$img_src100);
              }        
                if ((
    $sub == ".png") || ($sub == ".PNG")){   
      
                
    $image imagecreatefrompng($folder_scr."/".$img_src);
                list(
    $src_width$src_height) = getimagesize($folder_scr."/".$img_src);
                        if(
    $src_width >= $src_height)
                        {
                          
    $new_image_width $img_width;
                          
    $new_image_height $src_height $img_width $src_width;
                        }
                            if(
    $src_width $src_height)
                            {
                              
    $new_image_height $img_width;
                              
    $new_image_width $src_width $img_height $src_height;
                            }
                
    $new_image imagecreatetruecolor($new_image_width$new_image_height);
                
    imagecopyresampled($new_image$image0000$new_image_width,$new_image_height$src_width$src_height);
                
    imagepng($new_image$des_src."/".$img_src100);
                  }
      }
    // ende funktion

        
    $filename $_SERVER['PHP_SELF'];
          
    $verz=opendir($folder_scr);
          
    $linkl = array ();
          while (
    $file readdir ($verz))
          {
                if(
    $file != "." && $file != ".." && $file != $filename)
                {
                 
    array_push ($linkl"$file"); 
                }
          }
        
          
    $anzahl count($linkl);
          
    sort ($linkl);
          foreach(
    $linkl as $key => $value)
          {
                if(!
    file_exists($des_src."/".$value))
                {
                  
    view($value$thumbx$thumby$folder_scr$des_src);
                }
          }
        
          
    closedir($verz);
     

            
    $datum date("j.n.Y g:i:s");
            
    $ein "INSERT INTO file (name, time) VALUES ('$imgname', '$datum')";
            
    $eint mysql_query($ein);  

            
    exec('xcopy C:\apachefriends\xampp\htdocs\banp\admin1\upload C:\apachefriends\xampp\htdocs\banp\admin1\picture /e/i');
            
    header ("location: upload/index.php?id=$imgname");


    }else{
    header ("location: upload_5_admin1.php"); //muss ein jpq sein

    ich weiß nicht wo der fehler ist!

    Sicher ein kleiner fehler! ^^
    YOOO!! hunger!!

  • #2
    Du glaubst nicht wirklich, dass sich jemand die Mühe macht und dieses ellenlange Script durchsieht, oder?

    Wobei die Fehlerbesschreibung mehr als dürftig ist.

    PS: Die Headerangabe am Ende ist sowieso schonmal falsch, da dort was absolutes hin muss.

    Kommentar


    • #3
      setzt das error_reporting() mal auf E_ALL und grenz den fehler ein. so einen haufen spaghetticode schaut sich eh keiner an, schon garnicht wenn man quer scrollen muss.
      Kissolino.com

      Kommentar

      Lädt...
      X