Cibiņš Posted November 6, 2011 Report Share Posted November 6, 2011 Kapēc pie uploada resizējot bildi tā tiek pārvietota kā melna bilde?? <?php $uploadedfile = $_FILES['userfile']['tmp_name']; $filename = stripslashes($_FILES['userfile']['name']); if(isset($_FILES['userfile']['tmp_name'])){ function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $extension = getExtension($filename); $extension = strtolower($extension); list($width,$height)=getimagesize($uploadedfile); $newwidth=60; $newheight=($height/$width)*$newwidth; $tmp=imagecreatetruecolor($newwidth,$newheight); $newwidth1=25; $newheight1=($height/$width)*$newwidth1; $tmp1=imagecreatetruecolor($newwidth1,$newheight1); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); imagecopyresampled($tmp1,$src,0,0,0,0,$newwidth1,$newheight1,$width,$height); $flnm = substr(md5($_FILES['userfile']['name'].microtime().rand(1,100000)),0,30); $filename = "./". $flnm.'.'.$extension; $filename1 = "./small". $flnm.'.'.$extension; imagejpeg($tmp,$filename,100); imagejpeg($tmp1,$filename1,100); imagedestroy($src); imagedestroy($tmp); imagedestroy($tmp1); echo "success"; } else { echo "error"; } ?> Quote Link to comment Share on other sites More sharing options...
xPtv45z Posted November 6, 2011 Report Share Posted November 6, 2011 Ieslēdz, lai rāda notices un warningus, tad, gan jau, sapratīsi kāpēc. Jo pagaidām, tu tur izveido 2 melnas bildes un tādas viņas arī saglabā. Ko satur $src? Quote Link to comment Share on other sites More sharing options...
Cibiņš Posted November 6, 2011 Author Report Share Posted November 6, 2011 (edited) Ieslēdz, lai rāda notices un warningus, tad, gan jau, sapratīsi kāpēc. Jo pagaidām, tu tur izveido 2 melnas bildes un tādas viņas arī saglabā. Ko satur $src? Piedod, šodien esmu āzis :D Paldies, izlaidu cauri erroru debugerim un tieši dēļ tā src viņš dzina ārā melnas bildes. :) Šitais te pietrūka if($extension=="jpg" || $extension=="jpeg" ) { $src = imagecreatefromjpeg($uploadedfile); } else if($extension=="png") { $src = imagecreatefrompng($uploadedfile); } else { $src = imagecreatefromgif($uploadedfile); } Edited November 6, 2011 by Cibiņš Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.