Hello everyone and I hope you can help me
The problem is this, I have a form with the following code:
<form action="uploadernoticias.php" method="post" enctype="multipart/form-data" name="form1" class="nice" id="form1">
<h2>Insertar Noticias</h2>
<p class="left">
<label>Titulo</label>
<input name="caption" type="text" class="inputText" id="caption" />
<label>Imagen/Foto</label>
<input type="file" name="uploadedfile" id="uploadedfile" class="inputText" />
</p>
<p class="right">
<label>Description:</label>
<textarea name="contenido" cols="" rows="10" class="inputText_wide" id="contenido"></textarea>
<br clear="all" />
<button class="green" type="submit">Listo! - Subir Noticias</button>
</p>
<div class="clear"></div>
</form>
And the file uploadernoticias.php:
<?php
/*##################--[Obteniendo datos del formulario - Propiedades]*/
// Nombre
$caption = $_POST['caption'];
// Contenido
$contenido= $_POST['contenido'];
/*##################--[Definiendo la carpeta imagenes para las Propiedades]*/
$target_path = "../imagenes/noticias/";
/*##################--[Seteando las imagenes]*/
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
$file_path = basename( $_FILES['uploadedfile']['name']);
$file_size = basename( $_FILES['uploadedfile']['size']);
if ($file_size > '20452525'){
header('Location: gallery.php?id=error');
}
else
{
/*##################--[Informando si se subio correctamente entonces..]*/
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
//echo "The file ". basename( $_FILES['uploadedfile']['name']).
//" has been uploaded<br><br>Link: <a href=\"http://www.thetastingroomokc.com/gallery/". basename( $_FILES['uploadedfile']['name']) ."\">http://www.thetastingroomokc.com/gallery/". basename( $_FILES['uploadedfile']['name']) ."</a>";
/*##################--[Insertar en la base de datos]*/
mysql_query("INSERT INTO noticias VALUES ('', '$caption', '$contenido', '$file_path')");
//echo $file_size.' is how big your file is. It was transferred.';
/*##################--[Luego, enviar a una pagina]*/
header('Location: noticias.php');
} else{
echo "There was an error uploading the file, please try again!";
}
}
?>
The problem is that it gives me no error, nor rises to the database or upload images to the folders on the server.
What am I doing wrong?
Thank you and hope you can help me
Maybe you don't have write permission in target_path. Did you check it? Probably you don't see any error message because you have display_errors disabled (in php.ini). You could activate display_errors or activate logging in your server:
http://www.php.net/manual/en/errorfunc.configuration.php#ini.display-errors
http://www.php.net/manual/en/errorfunc.configuration.php#ini.log-errors
If you don't have access to configuration files, you can try this in your script:
ini_set('display_errors','On');
Try applying the right permissions to the upload folder, in most ftp browsers it's right click on the folder > file attributes or permissions, and set them to 777. Through SSH this would be: chmod -Rf 777 foldername