Ir para conteúdo

Arquivado

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

serginho_the_best

pq da erro na imagecreatefromstring()

Recommended Posts

olá fiz um sistema de dar upload em imagem e pequei um função de gerar thumb na net só que da erro olha:

 

index.php

<?phpinclude "funcao.php";if(isset($_POST["submit"])){	$file = isset($_FILES["file"]) ? $_FILES["file"] : false;	$dir = "uploads/".$file["name"];	if(!file_exists($dir)){		if(!eregi("^image\/(pjpeg|jpeg|png|gif|bmp)$", $file["type"])){			$error[] = "Arquivo com extensão inválido!";		}		else{			geraThumb($file["tmp_name"], $dir, 100);			$error[] = "Imagem enviada com sucesso!";		}	}	else{		$error[] = "Essa imagem já existe!";	}}?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Upload de Imagem</title></head><body><?phpif(isset($error)){	for($i=0;$i<count($error);$i++){		echo "<script>alert('".$error[$i]."');</script>";	}}?><form action="index.php" method="post" enctype="multipart/form-data"><input type="file" name="file" /><br /><input type="submit" name="submit" value="Enviar" /></form></body></html>

funcao.php

<?/* * Método geraThumb * Gera thumbnail a partir da foto */function geraThumb($photo, $output, $new_width){		$source = imagecreatefromstring(file_get_contents($photo));	list($width, $height) = getimagesize($photo);	if ($width>$new_width)	{		$new_height = ($new_width/$width) * $height;		$thumb = imagecreatetruecolor($new_width, $new_height);		imagecopyresampled($thumb, $source, 0, 0, 0, 0, $new_width, $new_height, $width, $height);		imagejpeg($thumb, $output, 100);	}	else	{		copy($photo, $output);	}}?>
pq da erro?

obrigado.

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.