Ver Mensaje Individual
  #1 (permalink)  
Antiguo 17/02/2012, 14:54
sahorykido1
 
Fecha de Ingreso: febrero-2012
Ubicación: Bogotá
Mensajes: 1
Antigüedad: 12 años, 2 meses
Puntos: 0
guadar fichero file y comprobar si existe

Buenas tardes, tengo una duda y una complicación con un código, es un formulario en php que cuenta para subir imágenes con file, pero esta no me las guarda en el servidor, lo que yo quiero es que solo en la base de datos me guarde el nombre y en una carpeta del servidor me guarde las imágenes, y que al momento de introducirlas este verifique si existen.... Gracias de antemano el que me pueda colaborar... este es el código


<?php require_once('../Connections/posada.php'); ?>
<?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;
}
}
$varusuario_Datoscarrito = "0";
if (isset($_SESSION['MM_Usuario'])) {
$varusuario_Datoscarrito = $_SESSION['MM_Usuario'];
}


$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 noticias (titulo, texto, fecha, img, img_completa) VALUES (%s, %s, %s, %s, %s)",
GetSQLValueString($_POST['titulo'], "text"),
GetSQLValueString($_POST['texto'], "text"),
GetSQLValueString($_POST['fecha'], "date"),
GetSQLValueString($_POST['img'], "text"),
GetSQLValueString($_POST['img_completa'], "text"));

mysql_select_db($database_posada, $posada);
$Result1 = mysql_query($insertSQL, $posada) or die(mysql_error());

$insertGoTo = "alta_noticias.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}

mysql_select_db($database_posada, $posada);
$query_Recordset1 = "SELECT * FROM noticias ORDER BY noticias.Id_noticia";
$Recordset1 = mysql_query($query_Recordset1, $posada) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

?>
<!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">


<link rel="stylesheet" type="text/css" href="css/default.css" />
<link rel="stylesheet" type="text/css" href="css/jquery-ui-1.7.2.custom.css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"></script>
<script src="../SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<script src="../SpryAssets/SpryValidationTextarea.js" type="text/javascript"></script>
<script type="text/javascript">
jQuery(function($){
$.datepicker.regional['es'] = {
closeText: 'Cerrar',
prevText: '&#x3c;Ant',
nextText: 'Sig&#x3e;',
currentText: 'Hoy',
monthNames: ['Enero','Febrero','Marzo','Abril','Mayo','Junio',
'Julio','Agosto','Septiembre','Octubre','Noviembre ','Diciembre'],
monthNamesShort: ['Ene','Feb','Mar','Abr','May','Jun',
'Jul','Ago','Sep','Oct','Nov','Dic'],
dayNames: ['Domingo','Lunes','Martes','Mi&eacute;rcoles','Jue ves','Viernes','S&aacute;bado'],
dayNamesShort: ['Dom','Lun','Mar','Mi&eacute;','Juv','Vie','S&aacu te;b'],
dayNamesMin: ['Do','Lu','Ma','Mi','Ju','Vi','S&aacute;'],
weekHeader: 'Sm',
dateFormat: 'yy/mm/dd',
firstDay: 1,
isRTL: false,
showMonthAfterYear: false,
yearSuffix: ''};
$.datepicker.setDefaults($.datepicker.regional['es']);
});

$(document).ready(function() {
$("#datepicker").datepicker();
});
</script>
<link href="../SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
<link href="../SpryAssets/SpryValidationTextarea.css" rel="stylesheet" type="text/css" />
<!-- InstanceBegin template="/Templates/BASEADMIN.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Noticias</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
<link href="estilos/twoColLiqLtHdr.css" rel="stylesheet" type="text/css" /><!--[if lte IE 7]>
<style>
.content { margin-right: -1px; } /* this 1px negative margin can be placed on any of the columns in this layout with the same corrective effect. */
ul.nav a { zoom: 1; } /* the zoom property gives IE the hasLayout trigger it needs to correct extra whiltespace between the links */
</style>
<![endif]-->
</head>

<body>

<div class="container">
<div class="header"><!-- end .header -->CABEZOTE</div>
<div class="sidebar1">
<ul class="nav">
<li> <?php include("include/cabeceradamin.php")?></li>
</ul>
<!-- end .sidebar1 --></div>
<div class="content">
<h1><!-- InstanceBeginEditable name="EditRegion3" -->NOTICIAS<br />
<br />

<!-- InstanceEndEditable --></h1>
<!-- InstanceBeginEditable name="EditRegion4" -->
<script>
function subirimagen()
{
self.name = "opener";
remote = open('gestionimagen.php', 'remote',
'width=400,height=150,location=no,scrollbars=yes,m enubars=no,toolbars=no,resizable=yes,fullscreen=no , status=yes');
remote.focus();
}
</script>

<script>
function subirimagen1()
{
self.name = "opener";
remote = open('gestionimagen1.php', 'remote',
'width=400,height=150,location=no,scrollbars=yes,m enubars=no,toolbars=no,resizable=yes,fullscreen=no , status=yes');
remote.focus();
}
</script>
<p>&nbsp;</p>
<form action="<?php echo $editFormAction; ?>" method="post" name="form2" id="form2" >
<table align="center">

<tr valign="baseline">
<td nowrap="nowrap" align="right">Título:</td>
<td><span id="sprytextfield1">
<input type="text" name="titulo" value="" size="50" />
<span class="textfieldRequiredMsg">Le falta el título.</span></span></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Fecha:</td>
<td><span id="sprytextfield2">
<input type="text" name="fecha" id="datepicker" value="" size="22" />
<span class="textfieldRequiredMsg">Le falta la fecha.</span></span></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Img:</td>
<td><input name="img" id="file" type="file" />

</td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Noticia:</td>
<td><label for="textarea"></label>
<span id="sprytextarea1">
<textarea type="text" name="texto" id="textarea" cols="65" rows="25"></textarea>
<span class="textareaRequiredMsg">colocar la descripción de la noticia.</span></span></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Img_completa:</td>
<td><input name="img_completa" id="file2" type="file" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">&nbsp;</td>
<td><input type="submit" value="Crear Noticia" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form2" />
</form>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<script type="text/javascript">
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2");
var sprytextarea1 = new Spry.Widget.ValidationTextarea("sprytextarea1");
</script>
<!-- InstanceEndEditable --><!-- end .content --></div>
<div class="footer">
<p>&nbsp;</p>
<!-- end .footer --></div>
<!-- end .container --></div>
</body>
<!-- InstanceEnd --></html>
<?php
mysql_free_result($Recordset1);


?>