Ir para conteúdo

POWERED BY:

Arquivado

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

israeloplopes

Upload no Dreamweaver com PHP

Recommended Posts

Segui um tutorial aqui do site funciona tudo só não faz o upload... tambem não dá erro... mas nao faz o upload

Se alguem puder me ajudar fico grato.

 

Segue abaixo o codigo :

 

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

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

{

$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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;

}

 

$editFormAction = $_SERVER['PHP_SELF'];

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

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

}

 

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form2")) {

$insertSQL = sprintf("INSERT INTO anuncio (idANUNCIO, idANUNCIANTE, DATACADASTRO, idGRUPO, TITULO, DESCRICAO, VALOR, FOTO1, FOTO2, FOTO3, FOTO4, PROPOSTA, LIBERADO, DESTAQUE, RECEBIDO) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",

GetSQLValueString($_POST['idANUNCIO'], "int"),

GetSQLValueString($_POST['idANUNCIANTE'], "int"),

GetSQLValueString($_POST['DATACADASTRO'], "date"),

GetSQLValueString($_POST['GRUPO'], "int"),

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

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

GetSQLValueString($_POST['VALOR'], "double"),

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

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

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

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

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

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

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

GetSQLValueString($_POST['RECEBIDO'], "text"));

 

mysql_select_db($database_mercadao, $mercadao);

$Result1 = mysql_query($insertSQL, $mercadao) or die(mysql_error());

}

 

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

$arquivo1 = $_FILES["FOTO1"];

$arquivo_nome1 = $arquivo1["name"];

$arquivo2 = $_FILES["FOTO2"];

$arquivo_nome2 = $arquivo2["name"];

$arquivo3 = $_FILES["FOTO3"];

$arquivo_nome3 = $arquivo3["name"];

$arquivo4 = $_FILES["FOTO4"];

$arquivo_nome4 = $arquivo4["name"];

$insertSQL = sprintf("INSERT INTO anuncio (idANUNCIO, idANUNCIANTE, DATACADASTRO, idGRUPO, TITULO, DESCRICAO, VALOR, FOTO1, FOTO2, FOTO3, FOTO4, PROPOSTA, LIBERADO, DESTAQUE, RECEBIDO) VALUES (%s, %s, %s, %s, %s, %s, %s, '$arquivo1_nome', '$arquivo2_nome', '$arquivo3_nome', '$arquivo4_nome', %s, %s, %s, %s)",

GetSQLValueString($_POST['idANUNCIO'], "int"),

GetSQLValueString($_POST['idANUNCIANTE'], "int"),

GetSQLValueString($_POST['DATACADASTRO'], "date"),

GetSQLValueString($_POST['idGRUPO'], "int"),

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

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

GetSQLValueString($_POST['VALOR'], "double"),

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

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

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

GetSQLValueString($_POST['RECEBIDO'], "text"));

 

 

 

 

 

mysql_select_db($database_mercadao, $mercadao);

$Result1 = mysql_query($insertSQL, $mercadao) or die(mysql_error());

 

$insertGoTo = "cpanel.php";

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

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

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

}

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

}

 

set_time_limit(0);

$diretorio = "fotoanuncio";

$id_arquivo = "foto1";

$nome_arquivo1 = $_FILES[$id_arquivo]["name"];

$arquivo_temporario = $_FILES[$id_arquivo]["tmp_name"];

move_uploaded_file($arquivo_temporario, "$diretorio/$nome_arquivo1");

 

$colname_rs_usuario = "1";

if (isset($_SESSION['MM_Username'])) {

$colname_rs_usuario = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']);

}

mysql_select_db($database_mercadao, $mercadao);

$query_rs_usuario = sprintf("SELECT * FROM usuario WHERE LOGIN = '%s' ORDER BY idUSUARIO ASC", $colname_rs_usuario);

$rs_usuario = mysql_query($query_rs_usuario, $mercadao) or die(mysql_error());

$row_rs_usuario = mysql_fetch_assoc($rs_usuario);

$totalRows_rs_usuario = mysql_num_rows($rs_usuario);

 

$colname_rs_anunciante = "1";

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

$colname_rs_anunciante = (get_magic_quotes_gpc()) ? $_GET['ANUNCIANTE'] : addslashes($_GET['ANUNCIANTE']);

}

mysql_select_db($database_mercadao, $mercadao);

$query_rs_anunciante = sprintf("SELECT * FROM anunciante WHERE idANUNCIANTE = %s", $colname_rs_anunciante);

$rs_anunciante = mysql_query($query_rs_anunciante, $mercadao) or die(mysql_error());

$row_rs_anunciante = mysql_fetch_assoc($rs_anunciante);

$totalRows_rs_anunciante = mysql_num_rows($rs_anunciante);

 

mysql_select_db($database_mercadao, $mercadao);

$query_rs_grupos = "SELECT * FROM grupos ORDER BY GRUPO ASC";

$rs_grupos = mysql_query($query_rs_grupos, $mercadao) or die(mysql_error());

$row_rs_grupos = mysql_fetch_assoc($rs_grupos);

$totalRows_rs_grupos = mysql_num_rows($rs_grupos);

 

session_start();

?>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<title>Mercadao Regional - Painel de Controle</title>

<link href="../estilo1.css" rel="stylesheet" type="text/css">

</head>

 

<body>

<div id="cabeca">

<div class="logo">

</div></div>

<div id="corpo">

<h3>Painel de Controle - Cadastra Anuncio </h3>

 

<p>  </p>

 

 

<form method="post" name="form2" action="<?php echo $editFormAction; ?>">

<table align="center">

<tr valign="baseline">

<td nowrap align="right">IdANUNCIANTE:</td>

<td><input type="text" name="idANUNCIANTE" value="<?php echo $row_rs_anunciante['idANUNCIANTE']; ?>" size="32"></td>

</tr>

<tr valign="baseline">

<td nowrap align="right">IdGRUPO:</td>

<td><select name="GRUPO" id="GRUPO">

<?php

do {

?>

<option value="<?php echo $row_rs_grupos['idGRUPO']?>"<?php if (!(strcmp($row_rs_grupos['idGRUPO'], $row_rs_grupos['idGRUPO']))) {echo "SELECTED";} ?>><?php echo $row_rs_grupos['GRUPO']?></option>

<?php

} while ($row_rs_grupos = mysql_fetch_assoc($rs_grupos));

$rows = mysql_num_rows($rs_grupos);

if($rows > 0) {

mysql_data_seek($rs_grupos, 0);

$row_rs_grupos = mysql_fetch_assoc($rs_grupos);

}

?>

</select></td>

</tr>

<tr valign="baseline">

<td nowrap align="right">TITULO:</td>

<td><input type="text" name="TITULO" value="" size="32"></td>

</tr>

<tr valign="baseline">

<td nowrap align="right">DESCRICAO:</td>

<td><input type="text" name="DESCRICAO" value="" size="32"></td>

</tr>

<tr valign="baseline">

<td nowrap align="right">VALOR:</td>

<td><input type="text" name="VALOR" value="" size="32"></td>

</tr>

<tr valign="baseline">

<td nowrap align="right">FOTO1:</td>

<td><input name="FOTO1" type="file" size="32"></td>

</tr>

<tr valign="baseline">

<td nowrap align="right">FOTO2:</td>

<td><input name="FOTO2" type="file" size="32"></td>

</tr>

<tr valign="baseline">

<td nowrap align="right">FOTO3:</td>

<td><input name="FOTO3" type="file" size="32"></td>

</tr>

<tr valign="baseline">

<td nowrap align="right">FOTO4:</td>

<td><input name="FOTO4" type="file" size="32"></td>

</tr>

<tr valign="baseline">

<td nowrap align="right">PROPOSTA:</td>

<td><input type="text" name="PROPOSTA" value="" size="32"></td>

</tr>

<tr valign="baseline">

<td nowrap align="right">DESTAQUE:</td>

<td><input type="text" name="DESTAQUE" value="" size="32"></td>

</tr>

<tr valign="baseline">

<td nowrap align="right"> </td>

<td><input type="submit" value="Insert record"></td>

</tr>

</table>

<input type="hidden" name="idANUNCIO" value="">

<input type="hidden" name="DATACADASTRO" value="">

<input type="hidden" name="LIBERADO" value="S">

<input type="hidden" name="RECEBIDO">

<input type="hidden" name="MM_insert" value="form2">

</form>

<p> </p>

<p> </p>

<p>Nome : <?php echo $_SESSION['MM_Username']; ?></p>

<p><?php echo $row_rs_usuario['idANUNCIANTE']; ?></p>

<p><?php echo $row_rs_anunciante['NOMECOMPLETO']; ?></p>

</div>

<div id="rodape">Desenvolvido por IPNet Sistemas - Todos os Direitos Reservados</div>

</body>

</html>

<?php

mysql_free_result($rs_usuario);

 

mysql_free_result($rs_anunciante);

 

mysql_free_result($rs_grupos);

?>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Bom, parece que você está utilizando o Dreamweaver para a obtenção do Upload...

Mas você todas as ferramentas nativas do software?

Compartilhar este post


Link para o post
Compartilhar em outros sites

Bom, parece que você está utilizando o Dreamweaver para a obtenção do Upload...

Mas você todas as ferramentas nativas do software?

Sim... estou usando o Dreamweaver MX 2004 sem nenhuma extension

Compartilhar este post


Link para o post
Compartilhar em outros sites

Amigo a sua TAG <FORM> ta errada, olha:

Você fez assim:

<form method="post" name="form2" action="<?php echo $editFormAction; ?>">

o certo é assim:

<form method="post" name="form2" action="<?php echo $editFormAction; ?>" enctype="multipart/form-data">
é o enctype que FAZ a magica.

 

Agora me responda, você seguio o tuto direito mesmo ou o tuto ta errado tambem. Por que se tiver me passa o link pra eu ir dar uns puxões de orelha no AUTOR. KKKK.

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.