Results 1 to 11 of 11
Hybrid View
-
25th October 2010 21:08 #1
!
.
:upload_small :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);
, 450 450 - thumbsCode: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; } }.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.
-
25th October 2010 23:34 #2
.

define("WIDTH",$pixel_size);
define("HEIGHT",$pixel_size);
, ... .
move_uploaded_file copy .''? * *
- !
...
-
26th October 2010 14:07 #3
!
2?upload_small($tmp_name,$file_type,$path_ small,150);
upload_small($tmp_name,$file_type,$path_ small3,450);.
-
26th October 2010 17:38 #4
, . , . , 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, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);//
imagejpeg($image_p, $path_small, 100);// 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, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);//
imagejpeg($image_p, $path_small, 100);// 100
}
}else{ echo ' !'; exit; }
}else{ echo ' !'; exit; }
?>''? * *
- !
...
-
26th October 2010 18:18 #5Registered User
Join Date: Jul:2005
Location: Sofiq
Posts: 2,798
and &&
Code:if($width<$constWidth and $height<$constHeight)
and. , , var_dump-$g = true && false; // $g will be assigned to (true && false) which is false
$h = true and false; // $h will be assigned to true
IE file type-a. .
-
27th October 2010 13:29 #6Hey, mother, I come bearing a gift. I'll give you a hint. It's in my diaper and it's not a toaster.
.
-
28th October 2010 11:21 #7
? "" , .
_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
-
26th October 2010 19:27 #8
.
@_ShadoW_ ?
..
:
68 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
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
$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.
.
-
27th October 2010 09:54 #9Registered User
Join Date: Jul:2005
Location: Sofiq
Posts: 2,798
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.
-
26th October 2010 20:49 #10
-
28th October 2010 12:03 #11''? * *
- !
...




Reply With Quote


Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in