Ir para conteúdo

POWERED BY:

Arquivado

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

Eduardo Kalsing

[Resolvido] Update de foto

Recommended Posts

Bom dia! Estou com dificuldade de encontrar uma lógica na forma de fazer update de fotos.

 

Tenho o seguinte código:

 

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
	
	$foto_pequena = $_POST['foto_pequena_velha'];
	$foto_grande = $_POST['foto_grande_velha'];
	$diretorio_p = "../lareiras/fotos_pequenas/";
	$diretorio_g = "../lareiras/fotos_grandes/";
	

	@unlink($diretorio_p."".$foto_pequena);

	@unlink($diretorio_g."".$foto_grande);

	 // ---------- IMAGE UPLOAD ----------
    
	
		$handle = new Upload($_FILES['foto_nova']);
	
		if ($handle->uploaded) {
			
			$handle->image_resize            = true;
			$handle->image_ratio_x           = true;
			$handle->image_y                 = 520;
			$handle->image_background_color = '#FFFFFF';
	
			$handle->Process('../lareiras/fotos_grandes/');
			
		
			$foto_grande_nova =  $handle->file_dst_name;
			$foto_temp =  $handle->file_src_pathname;
	
					// we now process the image a second time, with some other settings
					$handle->image_resize            = true;
					$handle->image_ratio_crop		 = true;
					$handle->image_x                = 185;
					$handle->image_y			     = 146;
					$handle->image_background_color = '#FFFFFF';
					$handle->image_contrast = 15;
				 
			
				 
			$handle->Process('../lareiras/fotos_pequenas/');
	
			// we check if everything went OK
       		 if ($handle->processed) {
         
       
	  		 } else {
       	 
			
         	 }
			
			// we delete the temporary files
			$foto_pequena_nova = $handle->file_dst_name;
			$handle-> Clean();
			
		}
	}	
	if(($_FILES['foto_nova']['size']) > 5){	
		$updateSQL = sprintf("UPDATE tbl_grupo_lareiras SET titulo=%s, descricao=%s, foto_pequena=%s, foto_grande=%s WHERE id=%s",
						   GetSQLValueString($_POST['titulo'], "text"),	
						   GetSQLValueString($_POST['message'], "text"),
						   GetSQLValueString($foto_pequena_nova, "text"),	
						   GetSQLValueString($foto_grande_nova, "text"),
						   GetSQLValueString($_POST['id'], "int"));
		echo $updateSQL; 					   
	} else {
		$updateSQL = sprintf("UPDATE tbl_grupo_lareiras SET titulo=%s, descricao=%s WHERE id=%s",
						   GetSQLValueString($_POST['titulo'], "text"),	
						   GetSQLValueString($_POST['message'], "text"),
						   GetSQLValueString($_POST['id'], "int"));
		echo $updateSQL;
	}
		mysql_select_db($database_conexao, $conexao);
	  	$Result1 = mysql_query($updateSQL, $conexao) or die(mysql_error());		 	 
	  
  echo "<script>
		alert('Grupo alterado com sucesso!')
		window.location='consultar-grupo-lareiras.php';
		</script>";

  $updateGoTo = "consultar-grupo-lareiras.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  //header(sprintf("Location: %s", $updateGoTo));
}

e ainda o input do file, com name de "foto_nova".

 

Se alguém puder me dar uma luz aí, agradeço!

 

Agora que vi que não coloquei meu problema.

O seguinte:

 

estou tentando fazer update da foto, mas não está rolando o update da foto, somente os demais dados.

Compartilhar este post


Link para o post
Compartilhar em outros sites

no seu form você colocou o enctype="multipart/form-data"

Compartilhar este post


Link para o post
Compartilhar em outros sites

Creio que você não esta levando o arquivo até o diretório. (Não li o arquivo por completo)

Reveja as funções de arquivos (move_uploaded_file();) Imagem Postada

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.