Ir para conteúdo

POWERED BY:

Arquivado

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

By@zinha

Problemas com Upload de imagens

Recommended Posts

Ola pessoal, ola Leandro como estão?

Leandro estou desenvolvendo o seu sistema de fotos e comentarios

Tudo funciona muito bem

So que agora vem apresentando um problema na pagina editar_fotos.php

Tudo se altera, menos a foto - hora ela some, hora permanece a mesma, mas alterar q é bom nada....

Eu uso o drean cs3 será uma cincompatibilidade com o seu tutorial

abaixo o codigo gerado pelo meu cream,

 

<?php require_once('../Connections/ConnAlbum.php'); ?>

<?php

if (!function_exists("GetSQLValueString")) {

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")

{

$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

 

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

 

switch ($theType) {

case "text":

$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

break;

case "long":

case "int":

$theValue = ($theValue != "") ? intval($theValue) : "NULL";

break;

case "double":

$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";

break;

case "date":

$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

break;

case "defined":

$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;

break;

}

return $theValue;

}

}

 

$colname_rsAlterarDadosFoto = "-1";

if (isset($_GET['foto_id'])) {

$colname_rsAlterarDadosFoto = $_GET['foto_id'];

}

mysql_select_db($database_ConnAlbum, $ConnAlbum);

$query_rsAlterarDadosFoto = sprintf("SELECT * FROM fotos WHERE foto_id = %s", GetSQLValueString($colname_rsAlterarDadosFoto, "int"));

$rsAlterarDadosFoto = mysql_query($query_rsAlterarDadosFoto, $ConnAlbum) or die(mysql_error());

$row_rsAlterarDadosFoto = mysql_fetch_assoc($rsAlterarDadosFoto);

$totalRows_rsAlterarDadosFoto = mysql_num_rows($rsAlterarDadosFoto);

 

o codigo alterado conforme instrução

<?php require_once('../Connections/ConnAlbum.php'); ?>

<?php

 

$colname_rsAlterarDadosFoto = "-1";

if (isset($_GET['foto_id'])) {

$colname_rsAlterarDadosFoto = $_GET['foto_id'];

}

mysql_select_db($database_ConnAlbum, $ConnAlbum);

$query_rsAlterarDadosFoto = sprintf("SELECT * FROM fotos WHERE foto_id = %s", GetSQLValueString($colname_rsAlterarDadosFoto, "int"));

$rsAlterarDadosFoto = mysql_query($query_rsAlterarDadosFoto, $ConnAlbum) or die(mysql_error());

$row_rsAlterarDadosFoto = mysql_fetch_assoc($rsAlterarDadosFoto);

$totalRows_rsAlterarDadosFoto = mysql_num_rows($rsAlterarDadosFoto);

 

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")

{

$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

 

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);com ou sem esta linha o erro permanece.

 

switch ($theType) {

case "text":

$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

break;

case "long":

case "int":

$theValue = ($theValue != "") ? intval($theValue) : "NULL";

break;

case "double":

$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";

break;

case "date":

$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

break;

case "defined":

$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;

break;

}

return $theValue;

}

$editFormAction = $_SERVER['PHP_SELF'];

if (isset($_SERVER['QUERY_STRING'])) {

$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);

}

 

$foto = $row_rsAlterarDadosFoto['foto_foto'];

$fotoTmp = $_FILES["foto_foto"]["tmp_name"];

 

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {

$updateSQL = sprintf("UPDATE fotos SET foto_foto='$foto', foto_titulo=%s, foto_legenda=%s WHERE foto_id=%s",

GetSQLValueString($_POST['foto_titulo'], "text"),

GetSQLValueString($_POST['foto_legenda'], "text"),

GetSQLValueString($_POST['foto_id'], "int"));

 

function geraImg($img, $max_x, $max_y, $imgNome) {

//pega o tamanho da imagem ($original_x, $original_y)

list($width, $height) = getimagesize($img);

$original_x = $width;

$original_y = $height;

// se a largura for maior que altura acho a porcentagem

if($original_x > $original_y) {

$porcentagem = (100 * $max_x) / $original_x;

}

else {

$porcentagem = (100 * $max_y) / $original_y;

}

$tamanho_x = $original_x * ($porcentagem / 100);

$tamanho_y = $original_y * ($porcentagem / 100);

$image_p = imagecreatetruecolor($tamanho_x, $tamanho_y);

$image = imagecreatefromjpeg($img);

imagecopyresampled($image_p, $image, 0, 0, 0, 0, $tamanho_x, $tamanho_y, $width, $height);

return imagejpeg($image_p, $imgNome, 100);

}

 

geraImg($fotoTmp, 640, 480, "fotos/".$foto); caminho do meu diretorio de fotos.

mysql_select_db($database_ConnAlbum, $ConnAlbum);

$Result1 = mysql_query($updateSQL, $ConnAlbum) or die(mysql_error());

 

$updateGoTo = "index.php";

if (isset($_SERVER['QUERY_STRING'])) {

$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";

$updateGoTo .= $_SERVER['QUERY_STRING'];

}

header(sprintf("Location: %s", $updateGoTo));

}

?>

 

Aguardo ajuda, porque estou desenvolvendo o sistema pra um site de cliente e esta me atrazando

Bya :blink:

Compartilhar este post


Link para o post
Compartilhar em outros sites

Problemas no Update mesmo, mas acho que isso seria uma questão mais pra PHP do que o pro Dreamweaver mesmo.

Mas você poderia mostrar o passo-a-passo do que você fez?

Compartilhar este post


Link para o post
Compartilhar em outros sites

Problemas no Update mesmo, mas acho que isso seria uma questão mais pra PHP do que o pro Dreamweaver mesmo.

Mas você poderia mostrar o passo-a-passo do que você fez?

Sim, claro, alias agradeço por responder

 

Eu segui o tutorial do Leando passo a passo no topico Alterar dados de Foto

http://imasters.com.br/artigo/3875/mys...dados_e_foto/no meu dream, originalmente o codigo fica assim

<?php require_once('../Connections/ConnAlbum.php'); ?>

<?php

if (!function_exists("GetSQLValueString")) {

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")

{

$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); - esta linha não consta no tutorial, mesmo tirando esta linha o erro permanece

 

 

Com as instruções do tudo, devo colocar o recordset acima do script de upload, ficando assim

 

<?php require_once('../Connections/ConnAlbum.php'); ?>

<?php

$colname_rsAlterarDadosFoto = "-1";

if (isset($_GET['foto_id'])) {

$colname_rsAlterarDadosFoto = $_GET['foto_id'];

}

mysql_select_db($database_ConnAlbum, $ConnAlbum);

$query_rsAlterarDadosFoto = sprintf("SELECT * FROM fotos WHERE foto_id = %s", GetSQLValueString($colname_rsAlterarDadosFoto, "int"));

$rsAlterarDadosFoto = mysql_query($query_rsAlterarDadosFoto, $ConnAlbum) or die(mysql_error());

$row_rsAlterarDadosFoto = mysql_fetch_assoc($rsAlterarDadosFoto);

$totalRows_rsAlterarDadosFoto = mysql_num_rows($rsAlterarDadosFoto);

 

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")

{

$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

 

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

 

switch ($theType) {

case "text":

$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

break;

case "long":

case "int":

$theValue = ($theValue != "") ? intval($theValue) : "NULL";

break;

case "double":

$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";

break;

case "date":

$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

break;

case "defined":

$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;

break;

}

return $theValue;

}

 

EU fiz um teste e a prieira fez, funcionou, depoisn ão mais

Ele não altera a imagem so o resto dos dados....

Pode ajudar. please??

Compartilhar este post


Link para o post
Compartilhar em outros sites

Bom, no artigo tem o código-fonte completo + arquivos utilizados. Você já tentou copiar/colar para ver se o erro persiste?

Compartilhar este post


Link para o post
Compartilhar em outros sites

Bom, no artigo tem o código-fonte completo + arquivos utilizados. Você já tentou copiar/colar para ver se o erro persiste?

Sim tentei sim

Usei as mesmos nomes no banco e na conexão

copiei o codigo da pagina editar_foto.php e nada

sei la o que houve....

talvez alguma coisa não configurada no meu php.. será??

Compartilhar este post


Link para o post
Compartilhar em outros sites

E no banco aconteceu a alteração?

Essa questão é importante pois pode definir se há erro na atualização ou se é um bug do DW na visualização.

Compartilhar este post


Link para o post
Compartilhar em outros sites

E no banco aconteceu a alteração?

Essa questão é importante pois pode definir se há erro na atualização ou se é um bug do DW na visualização.

No banco acontece a alteração dos dados, tipo legenda e titulo

A imagem não altera... tinha momentos q ela simplesmente sumia, mas isso eu ja achei o erro e arrumei

Agora é isso

So altera os outros dados no banco a imagem não

Compartilhar este post


Link para o post
Compartilhar em outros sites

Olá,

Olha no SQL desse arquivo ../Connections/ConnAlbum.php, aponta para o name do textfield corretamente.

Compartilhar este post


Link para o post
Compartilhar em outros sites

Olá,

Olha no SQL desse arquivo ../Connections/ConnAlbum.php, aponta para o name do textfield corretamente.

Creio de deva ser isso aki q você ta perguntando

 

Foi estipulada a variavel aki

 

$foto = $row_rsAlterarDadosFoto['foto_foto'];

$fotoTmp = $_FILES["foto_foto"]["tmp_name"];

 

$updateSQL = sprintf("UPDATE fotos SET foto_foto='$foto', foto_titulo=%s, foto_legenda=%s WHERE foto_id=%s",

GetSQLValueString($_POST['foto_titulo'], "text"),

GetSQLValueString($_POST['foto_legenda'], "text"),

GetSQLValueString($_POST['foto_id'], "int"));

 

Aguardo

 

OBS o codigo apresenta o mesmo problema no site

Compartilhar este post


Link para o post
Compartilhar em outros sites

Você observou essa parte do tuto? CLIQUE AQUI

 

Na página insere_foto.php ocorre algum problema?

 

Caso persista o erro, irei fazer o tutorial passo-a-passo hoje ou amanhã para ver de perto o erro.

Compartilhar este post


Link para o post
Compartilhar em outros sites

Você observou essa parte do tuto? CLIQUE AQUI

 

Na página insere_foto.php ocorre algum problema?

 

Caso persista o erro, irei fazer o tutorial passo-a-passo hoje ou amanhã para ver de perto o erro.

Sim esta tudo certinho

A foto insere sem problemas assim como comentario e ltitulo

Todo o tutorial esta completo, inclusive a pagina principal onde apresenta a ultima foto e seus comentarios e as 5 ultimas ( so não consegui mostrar em miniatura na index)

 

Tudo certo

So do editar mesmo q ta tendo problema com a foto

Se você fizer e puder verificar... porque nos comentarios da pagina do tutorial, uma pessoa teve o mesmo problema e o Leandro disse q possivelmente a foto estava em cahce, mas tbm ja vi, não esta

 

Obrigada

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.