Results 1 to 11 of 11

Thread:

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User ogun's Avatar
    Join Date: Jul:2009
    Location:
    Posts: 3,936

    !
    .
    :
    Code:
    $my_id = $_SESSION['logged_in_id'];
    			$random = rand(1000,9999);
    			$file_name = $random."_".time()."_".$_FILES['ufile']['name'];
    			$tmp_name=$_FILES['ufile']['tmp_name'];//     
    			$file_type=$_FILES['ufile']['type'];
    			$path_small="upload/".$my_id."/thumbs/".basename(strtolower($file_name));
    			$path_small2="upload/".$my_id."/images/".basename(strtolower($file_name));
    			$path_small3="upload/".$my_id."/thumbs2/".basename(strtolower($file_name));
    			upload_small($tmp_name,$file_type,$path_small,150);
    			upload_small($tmp_name,$file_type,$path_small3,450);
    			move_uploaded_file($tmp_name,$path_small2);
    upload_small :
    Code:
    function upload_small($tmp_name,$file_type,$path_small,$pixel_size){//upload        
    		if(!file_exists($path_small)){//      
    			if($file_type=="image/pjpeg" || $file_type=="image/jpeg" || $file_type=="image/gif" || $file_type=="image/x-png" || $file_type=="image/png"){//    
    				list($width,$height)=getimagesize($tmp_name);
    				define("WIDTH",$pixel_size);// 150  -     150  
    				define("HEIGHT",$pixel_size);// 150  -     150  
    				if($width<WIDTH and $height<HEIGHT){//     -  WIDTH  HEIGHT
    					move_uploaded_file($tmp_name,$path_small);
    				}elseif($width>=WIDTH){//   -    WIDTH
    					$new_width= WIDTH;//   
    					$new_height= (int) ($height*$new_width)/$width;//   
    					//      
    					if($file_type=="image/pjpeg" or $file_type=="image/jpeg"){
    						$imagecreatefrom="imagecreatefromjpeg";
    					}elseif($file_type=="image/gif"){
    						$imagecreatefrom="imagecreatefromgif";
    					}elseif($file_type=="image/x-png" or $file_type=="image/png"){
    						$imagecreatefrom="imagecreatefrompng";
    					}
    					//        
    					$image_p=imagecreatetruecolor($new_width, $new_height);//      
    					$image=$imagecreatefrom($tmp_name);//   
    					imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);//   
    					imagejpeg($image_p, $path_small, 100);//      100
    				}elseif($height>=HEIGHT){//   -    HEIGHT
    					$new_height= HEIGHT;//   
    					$new_width= (int) ($width*$new_height)/$height;//   
    					//      
    					if($file_type=="image/pjpeg" or $file_type=="image/jpeg"){
    						$imagecreatefrom="imagecreatefromjpeg";
    					}elseif($file_type=="image/gif"){
    						$imagecreatefrom="imagecreatefromgif";
    					}elseif($file_type=="image/x-png" or $file_type=="image/png"){
    						$imagecreatefrom="imagecreatefrompng";
    					}
    					//        
    					$image_p=imagecreatetruecolor($new_width, $new_height);//      
    					$image=$imagecreatefrom($tmp_name);//   
    					imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);//   
    					imagejpeg($image_p, $path_small, 100);//      100
    				}
    			}else{ echo '   !'; exit; }
    		}else{ echo '   !'; exit; }
    }
    , 450 450 - thumbs
    Warning: getimagesize(D:\codes\xampp\tmp\phpFEF3. tmp) [function.getimagesize]: failed to open stream: No such file or directory in D:\codes\xampp\htdocs\wall\function.php on line 50
    .
    .

  2. #2
    ! vbTheKing's Avatar
    Join Date: Sep:2003
    Location:
    Posts: 4,138
    .

    define("WIDTH",$pixel_size);
    define("HEIGHT",$pixel_size);

    , ... .

    move_uploaded_file copy .
    ''? * *
    - !
    ...

  3. #3
    Registered User ogun's Avatar
    Join Date: Jul:2009
    Location:
    Posts: 3,936
    !
    2
    upload_small($tmp_name,$file_type,$path_ small,150);
    upload_small($tmp_name,$file_type,$path_ small3,450);
    ?
    .

  4. #4
    ! vbTheKing's Avatar
    Join Date: Sep:2003
    Location:
    Posts: 4,138
    , . , . , error_reporting .
    , , , .
    PHP Code:
    <?php
    function upload_small($tmp_name,$file_type,$path_small,$pixel_size){//upload        
            
    if(!file_exists($path_small)){//      
                
    if($file_type=="image/pjpeg" || $file_type=="image/jpeg" || $file_type=="image/gif" || $file_type=="image/x-png" || $file_type=="image/png"){//    
                    
    list($width,$height)=getimagesize($tmp_name);
                    
    $constWidth $pixel_size;// 150  -     150  
                    
    $constHeight pixel_size;// 150  -     150  
                    
    if($width<$constWidth and $height<$constHeight){//     -  WIDTH  HEIGHT
                        
    copy($tmp_name,$path_small);
                    }elseif(
    $width>=$constWidth){//   -    WIDTH
                        
    $new_width$constWidth;//   
                        
    $new_height= (int) ($height*$new_width)/$width;//   
                        //      
                        
    if($file_type=="image/pjpeg" or $file_type=="image/jpeg"){
                            
    $imagecreatefrom="imagecreatefromjpeg";
                        }elseif(
    $file_type=="image/gif"){
                            
    $imagecreatefrom="imagecreatefromgif";
                        }elseif(
    $file_type=="image/x-png" or $file_type=="image/png"){
                            
    $imagecreatefrom="imagecreatefrompng";
                        }
                        
    //        
                        
    $image_p=imagecreatetruecolor($new_width$new_height);//      
                        
    $image=$imagecreatefrom($tmp_name);//   
                        
    imagecopyresampled($image_p$image0000$new_width$new_height$width$height);//   
                        
    imagejpeg($image_p$path_small100);//      100
                    
    }elseif($height>=$constHeight){//   -    HEIGHT
                        
    $new_height$constHeight;//   
                        
    $new_width= (int) ($width*$new_height)/$height;//   
                        //      
                        
    if($file_type=="image/pjpeg" or $file_type=="image/jpeg"){
                            
    $imagecreatefrom="imagecreatefromjpeg";
                        }elseif(
    $file_type=="image/gif"){
                            
    $imagecreatefrom="imagecreatefromgif";
                        }elseif(
    $file_type=="image/x-png" or $file_type=="image/png"){
                            
    $imagecreatefrom="imagecreatefrompng";
                        }
                        
    //        
                        
    $image_p=imagecreatetruecolor($new_width$new_height);//      
                        
    $image=$imagecreatefrom($tmp_name);//   
                        
    imagecopyresampled($image_p$image0000$new_width$new_height$width$height);//   
                        
    imagejpeg($image_p$path_small100);//      100
                    
    }
                }else{ echo 
    '   !'; exit; }
            }else{ echo 
    '   !'; exit; }

    ?>
    ''? * *
    - !
    ...

  5. #5
    Registered User
    Join Date: Jul:2005
    Location: Sofiq
    Posts: 2,798
    and &&
    Code:
    if($width<$constWidth and $height<$constHeight)
    $g = true && false; // $g will be assigned to (true && false) which is false
    $h = true and false; // $h will be assigned to true
    and. , , var_dump-

    IE file type-a. .

  6. #6
    hmm BornToDrink's Avatar
    Join Date: Aug:2005
    Location: .
    Posts: 11,573
    Quote Originally Posted by _ShadoW_ View Post
    and &&
    Code:
    if($width<$constWidth and $height<$constHeight)

    and. , , var_dump-
    , , ...
    , .
    && , .
    Hey, mother, I come bearing a gift. I'll give you a hint. It's in my diaper and it's not a toaster.
    .

  7. #7
    Deleted User 4eRNoBiL's Avatar
    Join Date: Oct:2005
    Location:
    Posts: 739
    ? "" , .

    _ShadoW_:
    Code:
    $g = true && false; // $g will be assigned to (true && false) which is false
    $h = true and false; // $h will be assigned to true
    ,
    "$h = true and false;" "$h = true || false;"? $h true. ogun, .

    , , , . , , - "and". , , .
    Fujistu Lifebook E756 | Core i7-6500U / 400MHz-3.1GHz | 8 GB DDR4-2133 | Samsung PM871 / 256 GB SSD | 15" 1920x1080 | Manjaro Linux + kernel 4.19

  8. #8
    Registered User ogun's Avatar
    Join Date: Jul:2009
    Location:
    Posts: 3,936
    .
    @_ShadoW_ ?

    ..
    :
    Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: gd-jpeg, libjpeg: recoverable error: Premature end of JPEG file in D:\codes\xampp\htdocs\wall\function.php on line 68

    Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: 'D:\codes\xampp\tmp\php456A.tmp' is not a valid JPEG file in D:\codes\xampp\htdocs\wall\function.php on line 68

    Warning: imagecopyresampled() expects parameter 2 to be resource, boolean given in D:\codes\xampp\htdocs\wall\function.php on line 69

    Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: gd-jpeg, libjpeg: recoverable error: Premature end of JPEG file in D:\codes\xampp\htdocs\wall\function.php on line 68

    Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: 'D:\codes\xampp\tmp\php456A.tmp' is not a valid JPEG file in D:\codes\xampp\htdocs\wall\function.php on line 68

    Warning: imagecopyresampled() expects parameter 2 to be resource, boolean given in D:\codes\xampp\htdocs\wall\function.php on line 69
    68 69 :
    $image=$imagecreatefrom($tmp_name);//
    imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);//
    Last edited by ogun; 26th October 2010 at 19:50.
    .

  9. #9
    Registered User
    Join Date: Jul:2005
    Location: Sofiq
    Posts: 2,798
    Quote Originally Posted by ogun View Post
    .
    @_ShadoW_ ?
    ImageMagic . , 2Mb.

    :

    Code:
    <?php
    function upload_small($tmp_name, $path_small, $pixel_size){//upload        
    	if(file_exists($path_small)) return '   !';
    	
    	list($width,$height)=getimagesize($tmp_name);
    	
    	if(!($width > 0)) return '   !';
    	
    	if($width<$pixel_size && $height<$pixel_size){//     -  WIDTH  HEIGHT
    		copy($tmp_name,$path_small);
    	}else{
    		system('convert '.$tmp_name.' -resize '.$pixel_size.'x -resize \'x'.$pixel_size.'<\' -resize 50% -gravity center -crop '.$pixel_size.'x'.$pixel_size.'+0+0 +repage '.$path_small);
    	}
    	
    	if(!is_file($path_small)) return ' !';
    	
    	return true;
    }
    ?>
    Last edited by _ShadoW_; 27th October 2010 at 10:07.

  10. #10
    ! vbTheKing's Avatar
    Join Date: Sep:2003
    Location:
    Posts: 4,138
    . . JPG .
    ''? * *
    - !
    ...

  11. #11

Posting Permissions

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

Copyright © 1999-2011 . .
iskamPC.com | mobility.BG | Bloody's Techblog | | 3D Vision Blog |