Venho por meio deste solicitar uma ajuda para implementar o código php gerado pelo Dreamweaver CS4 na criação de um formulário para upload de imagens. O sistema funciona, mas as imagens não são enviadas para o diretorio "fotos" que está no diretório raiz. Preciso de ajuda para que o form possa ser implementado e cumprir essa função.
Eis o dódigo PHP (Abaixo o Formulário):
CODE
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$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;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO galeria_fotos (foto_descricao, foto_1) VALUES (%s, %s)",
GetSQLValueString($_POST['foto_descricao'], "text"),
GetSQLValueString($_POST['foto_1'], "text"));
mysql_select_db($database_artigosAd, $artigosAd);
$Result1 = mysql_query($insertSQL, $artigosAd) or die(mysql_error());
$insertGoTo = "manutencao.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_artigosAd, $artigosAd);
$query_rsFotos = "SELECT * FROM galeria_fotos";
$rsFotos = mysql_query($query_rsFotos, $artigosAd) or die(mysql_error());
$row_rsFotos = mysql_fetch_assoc($rsFotos);
$totalRows_rsFotos = mysql_num_rows($rsFotos);
?>
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$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;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO galeria_fotos (foto_descricao, foto_1) VALUES (%s, %s)",
GetSQLValueString($_POST['foto_descricao'], "text"),
GetSQLValueString($_POST['foto_1'], "text"));
mysql_select_db($database_artigosAd, $artigosAd);
$Result1 = mysql_query($insertSQL, $artigosAd) or die(mysql_error());
$insertGoTo = "manutencao.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_artigosAd, $artigosAd);
$query_rsFotos = "SELECT * FROM galeria_fotos";
$rsFotos = mysql_query($query_rsFotos, $artigosAd) or die(mysql_error());
$row_rsFotos = mysql_fetch_assoc($rsFotos);
$totalRows_rsFotos = mysql_num_rows($rsFotos);
?>
Aqui a marcação do Formulário.
CODE
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<fieldset>
<label>Descrição:</label><br/>
<input type="text" name="foto_descricao" value="" size="32" /><br/>
<label>Foto:</label><br/>
<input type="file" name="foto_1" value="" size="32" /><br/>
<input type="submit" value="Gravar Foto" />
</fieldset>
<input type="hidden" name="MM_insert" value="form1" />
</form>
<fieldset>
<label>Descrição:</label><br/>
<input type="text" name="foto_descricao" value="" size="32" /><br/>
<label>Foto:</label><br/>
<input type="file" name="foto_1" value="" size="32" /><br/>
<input type="submit" value="Gravar Foto" />
</fieldset>
<input type="hidden" name="MM_insert" value="form1" />
</form>
Desde já agradeço a todos que se interessaram pelo post com o intuido de ajudar.
Valew!

Help














