Janelee 0 Denunciar post Postado Julho 28, 2009 Olá colegas ;D Estou com um grande problema com um script para cadastro de imagens. Utilizei este mesmo em um projeto anterior, adaptado as minhas necessidades, que funcionava perfeitamente. Mas, ao reutiliza-lo em um outro projeto, modificando somente as tabelas do banco e dados, ja não consegui obter o funcionamento. fiz então alguns testes de escrita para saber até que variável ele estava recebendo os dados. Obtive resultado na tela até a variável $Destinob. O banco de dados deste projeto não é muito diferente do anterior, então não sei o que pode estar ocorrendo. Help me please? :D processa_upload.php <? include "valida_cookies.php"; include "config.php"; $cat = $_POST['categoria']; echo "Categoria : ".$cat."<br>"; //provisorio... mostrar a categoria que chega $verifi_cat = mysql_query("SELECT * FROM $tfotos WHERE idcatfotos='$cat'"); $result = mysql_num_rows($verifi_cat); if($result){ $del = mysql_query("DELETE FROM $tfotos WHERE idcatfotos='$cat'"); } ?> <!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=utf-8" /> <title>Untitled Document</title> <link href="css/estrutura.css" rel="stylesheet" type="text/css" /> <script src="Scripts/swfobject_modified.js" type="text/javascript"></script> <style type="text/css"> <!-- body { background-color: #CAEAFF; } --> </style> </head> <body> <div id="fundo"> <div id="componentes"> <div id="titulo"> <object id="FlashID" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="600" height="200"> <param name="movie" value="swf/topo_admin.swf" /> <param name="quality" value="high" /> <param name="wmode" value="transparent" /> <param name="swfversion" value="9.0.45.0" /> <!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you don’t want users to see the prompt. --> <param name="expressinstall" value="Scripts/expressInstall.swf" /> <!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. --> <!--[if !IE]>--> <object type="application/x-shockwave-flash" data="swf/topo_admin.swf" width="600" height="200"> <!--<![endif]--> <param name="quality" value="high" /> <param name="wmode" value="transparent" /> <param name="swfversion" value="9.0.45.0" /> <param name="expressinstall" value="Scripts/expressInstall.swf" /> <!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. --> <div> <h4>Content on this page requires a newer version of Adobe Flash Player.</h4> <p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" width="112" height="33" /></a></p> </div> <!--[if !IE]>--> </object> <!--<![endif]--> </object> </div> <!--COMECAR A POR AQUIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII--> <div id="escolha" align="center"> <? // Pasta de destino das fotos $Destino = '../fotos/'; $Destinob = 'fotos/'; // Obtém dados do upload $Fotos = $_FILES['fotos']; // Contagem de fotos enviadas $Conta = 0; // Itera sobre as enviadas e processa as validações e upload for($i = 0; $i < sizeof($Fotos['name']); $i++) { // Passa valores da iteração atual $Nome = $Fotos['name'][$i]; $Tamanho = $Fotos['size'][$i]; $Tipo = $Fotos['type'][$i]; $Tmpname = $Fotos['tmp_name'][$i]; // Verifica se tem arquivo enviado if($Tamanho > 0 && strlen($Nome) > 1) { // Verifica se é uma imagem if(preg_match('/^image\/(.*)?(gif|jpeg|jpg|png)$/', $Tipo)) { //set_time_limit(0); // Caminho completo de destino da foto $Caminho = $Destino . $Nome; $Caminhob = $Destinob . $Nome; echo "ok"; // Tudo OK! Move o upload!> if(move_uploaded_file($Tmpname, $Caminho)) { $enserir = mysql_query("INSERT INTO fotos(idcatfotos,enderecoimg) VALUES('{$cat}','{$Caminhob}')"); echo "<div style=\"postition:relative;float:left;padding:5px;\"><img src=".$Caminho." width=120 height=130></div>"; } else // Erro no envio { // $i+1 porque $i começa em zero echo 'Não foi possível enviar a foto<br/>'; } } } } if($enserir){ echo "<div style='clear:both;'>Dados cadastrados com sucesso</div><br> <div style='clear:both;'>Dados:<br> $texto</div>"; }else{ echo "Erro ao cadastrar imagens"; } ?> </div> <!--TERMINAR DE POR--> </div> </div> <script type="text/javascript"> <!-- swfobject.registerObject("FlashID"); //--> </script> <? echo "$Caminho"; ?> </body> </html> banco de dados -- Versão do Servidor: 5.0.67 -- Versão do PHP: 5.2.6 SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; -- -- Banco de Dados: `tridez_julier` -- -- -------------------------------------------------------- -- -- Estrutura da tabela `categorias` -- CREATE TABLE IF NOT EXISTS `categorias` ( `idcategoria` int(11) NOT NULL, `categoria` char(100) collate utf8_unicode_ci NOT NULL, PRIMARY KEY (`idcategoria`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- -- Extraindo dados da tabela `categorias` -- INSERT INTO `categorias` (`idcategoria`, `categoria`) VALUES (1, 'Casamentos'), (2, 'Books'), (3, '15 anos'), (4, 'Publicidade'); -- -------------------------------------------------------- -- -- Estrutura da tabela `fotos` -- CREATE TABLE IF NOT EXISTS `fotos` ( `idfoto` int(11) NOT NULL auto_increment, `enderecoimg` varchar(200) collate utf8_unicode_ci NOT NULL, `miniatura` varchar(200) collate utf8_unicode_ci NOT NULL, `idcatfotos` int(11) NOT NULL, PRIMARY KEY (`idfoto`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=7 ; -- -- Extraindo dados da tabela `fotos` -- INSERT INTO `fotos` (`idfoto`, `enderecoimg`, `miniatura`, `idcatfotos`) VALUES (6, 'fotos/DSC01021.JPG', '', 0); -- -------------------------------------------------------- -- -- Estrutura da tabela `servicos` -- CREATE TABLE IF NOT EXISTS `servicos` ( `idservico` int(11) NOT NULL auto_increment, `servico` char(80) collate utf8_unicode_ci NOT NULL, `imga` varchar(200) collate utf8_unicode_ci NOT NULL, `imgb` varchar(200) collate utf8_unicode_ci NOT NULL, `imgc` varchar(200) collate utf8_unicode_ci NOT NULL, PRIMARY KEY (`idservico`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; -- -- Extraindo dados da tabela `servicos` -- -- -------------------------------------------------------- -- -- Estrutura da tabela `usuarios` -- CREATE TABLE IF NOT EXISTS `usuarios` ( `idusuario` int(11) NOT NULL auto_increment, `nome` varchar(100) collate utf8_unicode_ci NOT NULL, `login` char(10) collate utf8_unicode_ci NOT NULL, `senha` char(10) collate utf8_unicode_ci NOT NULL, PRIMARY KEY (`idusuario`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=12 ; -- -- Extraindo dados da tabela `usuarios` -- INSERT INTO `usuarios` (`idusuario`, `nome`, `login`, `senha`) VALUES (4, 'bruna', 'bruna', '123'), (6, 'Julier', 'julier', '321'); Se ficar duvidas. segue abaixo os formularios de cadastro cadfotos.php <? include "config.php"; ?> <!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=utf-8" /> <title>Untitled Document</title> <link href="css/estrutura.css" rel="stylesheet" type="text/css" /> <script src="Scripts/swfobject_modified.js" type="text/javascript"></script> <style type="text/css"> <!-- body { background-color: #CAEAFF; } --> </style> <script> var requi; function criaCampos(quantidade) { var url = "quantidade=" + quantidade ; //Verificar o Browser if(window.XMLHttpRequest) { requi = new XMLHttpRequest(); } else if(window.ActiveXObject) { requi = new ActiveXObject("Microsoft.XMLHTTP"); } requi.open("POST", "geraCampos.php", true); requi.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); requi.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate"); requi.setRequestHeader("Cache-Control", "post-check=0, pre-check=0"); requi.setRequestHeader("Pragma", "no-cache"); requi.setRequestHeader('Content-length', url.length ); requi.onreadystatechange = callbacki; requi.send(url); } function callbacki() { if(requi.readyState == 4) { if(requi.status == 200) { var respostai = requi.responseText; document.getElementById('FormCampos').innerHTML = respostai; } } } function limpaForm() {//Limpeza dos campos do fomulário principal document.getElementById('quantidade').value = ''; } </script></head> <body> <div id="fundo"> <div id="componentes"> <div id="titulo"> <object id="FlashID" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="600" height="200"> <param name="movie" value="swf/topo_admin.swf" /> <param name="quality" value="high" /> <param name="wmode" value="transparent" /> <param name="swfversion" value="9.0.45.0" /> <!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you don’t want users to see the prompt. --> <param name="expressinstall" value="Scripts/expressInstall.swf" /> <!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. --> <!--[if !IE]>--> <object type="application/x-shockwave-flash" data="swf/topo_admin.swf" width="600" height="200"> <!--<![endif]--> <param name="quality" value="high" /> <param name="wmode" value="transparent" /> <param name="swfversion" value="9.0.45.0" /> <param name="expressinstall" value="Scripts/expressInstall.swf" /> <!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. --> <div> <h4>Content on this page requires a newer version of Adobe Flash Player.</h4> <p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" width="112" height="33" /></a></p> </div> <!--[if !IE]>--> </object> <!--<![endif]--> </object> </div> <!--COMECAR A POR AQUIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII--> <div id="escolha" align="center"> <form > Determine aqui a quantidade de fotos: <br /> <input type="hidden" name="cat" value="<?=$selecao?>"/> <input type="text" name="quantidade" size="5"/><br /> <input type="button" name="btnenviar" value="OK" onclick="criaCampos(document.getElementById('quantidade').value);limpaForm();"/> </form> <div id="formCampos"> </div> <form action="processa_upload.php" method="POST" enctype="multipart/form-data"> Escolha uma categoria:<br> <select name="categoria" id="categoria"> <? $verif= mysql_query("SELECT * FROM $tcategorias"); while($result = mysql_fetch_array($verif)){?> <option value="<?=$result['idcategoria']?>"><?=$result['categoria']?></option> <? } ?> </select> <p> <input type="submit" value="Enviar"/> </p> </form> </div> <!--TERMINAR DE POR--> </div> </div> <script type="text/javascript"> <!-- swfobject.registerObject("FlashID"); //--> </script> </body> </html> geraCampos.php <?php include "config.php"; $Quantidade = (isset($_POST['quantidade']) && is_int(intval($_POST['quantidade']))) ? (int)$_POST['quantidade'] : 0; // Abre formulário de upload echo '<b>Envio das fotos</b><br>'; // Imprime os campos para upload, de acordo com a quantidade pedida for($i = 1; $i <= $Quantidade; ++$i) { echo 'Página ' . $i . ': <input type="file" name="fotos[]" /><br/>'; } ?> Compartilhar este post Link para o post Compartilhar em outros sites
Matias Rezende 50 Denunciar post Postado Julho 28, 2009 Qual erro aparece? O que acontece e o que deveria acontecer? Ajude-nos a te ajudar. Carlos Eduardo Compartilhar este post Link para o post Compartilhar em outros sites
Janelee 0 Denunciar post Postado Julho 28, 2009 Aa, desculpa. :x Ele pega aquele erro que contem no código "Erro ao cadastrar imagens" Ele deveria inserir e aparecer as imagens em miniatura. Compartilhar este post Link para o post Compartilhar em outros sites
Janelee 0 Denunciar post Postado Julho 29, 2009 ok. consegui resolver. http://forum.imasters.com.br/public/style_emoticons/default/joia.gif Compartilhar este post Link para o post Compartilhar em outros sites