Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

rafaellferreira14

redimensionamento Uploadify

Recommended Posts

Boa tarde amigos, estou com um probleminha no uploadify, ele faz o upload blz, redminensiona para a largura e tudo mais, segue o codigo dele:

<?php
if (!empty($_FILES)) {
	$idPai = $_POST['Session'];
	$postId		= $_POST['postId'];
    $img        = $_FILES['Filedata']['name'];
	$img_nome 	= $_FILES['Filedata']['name'];
	$ext        = substr($img, -4);
	$img        = $postId.'-'.md5(uniqid(time())).$ext;
	$targetPath = $_SERVER['DOCUMENT_ROOT'].$_REQUEST['folder'].'/';
	$m = date('m');
	$y = date('Y');
	if(!file_exists($targetPath.$y)){ mkdir($targetPath.$y,0755);}
	if(!file_exists($targetPath.$y.'/'.$m)){ mkdir($targetPath.$y.'/'.$m,0755);}
	$targetPath = $_SERVER['DOCUMENT_ROOT'].$_REQUEST['folder'].'/'.$y.'/'.$m.'/';
	$tempFile = $_FILES['Filedata']['tmp_name'];
	$targetFile =  str_replace('//','/',$targetPath).$img;
	
		$imgCad = $y.'/'.$m.'/'.$img;
		$timestamp = date('Y-m-d H:i:s');
		$cadastra = mysql_query("INSERT INTO up_posts_gb(post_id, id_pai, img_nome, img, data) VALUES('$postId', '$idPai', '$img_nome', '$imgCad', '$timestamp')");
		print( mysql_error() );
		$cadastra1 = mysql_query("INSERT INTO up_vendas(post_id, id_pai, img_nome, img, data) VALUES('$postId', '$idPai', '$img_nome', '$imgCad', '$timestamp')");
		print( mysql_error() );
		
		
}
	
	move_uploaded_file($tempFile,$targetFile);
	str_replace($_SERVER['DOCUMENT_ROOT'],'',$targetFile);
	
	$imgsize = getimagesize($targetFile);
	switch(strtolower(substr($targetFile, -3))){
		case "jpg":
			$image = imagecreatefromjpeg($targetFile);    
		break;
		case "png":
			$image = imagecreatefrompng($targetFile);
		break;
		case "gif":
			$image = imagecreatefromgif($targetFile);
		break;
		default:
			exit;
		break;
	}
	
	$width = 800;  
	$height = $imgsize[1]/$imgsize[0]*$width;
	
	$src_w = $imgsize[0];
	$src_h = $imgsize[1];
	
	$picture = imagecreatetruecolor($width, $height);
	imagealphablending($picture, false);
	imagesavealpha($picture, true);
	$bool = imagecopyresampled($picture, $image, 0, 0, 0, 0, $width, $height, $src_w, $src_h); 
	
	if($bool){
		switch(strtolower(substr($targetFile, -3))){
			case "jpg":
				header("Content-Type: image/jpeg");
				$bool2 = imagejpeg($picture,$targetPath.$img,80);
			break;
			case "png":
				header("Content-Type: image/png");
				imagepng($picture,$targetPath.$img);
			break;
			case "gif":
				header("Content-Type: image/gif");
				imagegif($picture,$targetPath.$img);
			break;
		}
	}
	
		imagedestroy($picture);
		imagedestroy($image);
		echo '1';
?>

ok, a linha:

 

$bool2 = imagejpeg($picture,$targetPath.$img,80);

 

faz uma redução significante do tamanho da imagem, tipo uma foto de 5 mb vai pra 300kb, ai vem o problema... localhost isso funciona perfeitamente, na hospedagem hostgator funciona perfeitamente, na locaweb e na uolhost nao funciona, nessas duas so faz o resize para 800 que está definido nas seguintes linhas:

 

$width = 800;

$height = $imgsize[1]/$imgsize[0]*$width;

 

eu acredito que seja alguma configuracao do php do servidor, alguem pode me da uma luz?

Compartilhar este post


Link para o post
Compartilhar em outros sites

ja entrou em contato com o suporte deles para ver o que falam a respeito?

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.