大家好,我希望你能帮助我
问题在于,我有一个包含以下代码的表单:
<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>
文件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!";
}
}
?>
问题是它没有给我任何错误,也没有上升到数据库或将图像上传到服务器上的文件夹。
我做错了什么?
谢谢你,希望你能帮帮我
答案 0 :(得分:1)
也许你没有target_path的写权限。你检查过了吗?可能您没有看到任何错误消息,因为您已禁用display_errors(在php.ini中)。您可以激活display_errors或激活服务器中的日志记录:
http://www.php.net/manual/en/errorfunc.configuration.php#ini.display-errors
http://www.php.net/manual/en/errorfunc.configuration.php#ini.log-errors
如果您无权访问配置文件,可以在脚本中尝试:
ini_set('display_errors','On');
答案 1 :(得分:0)
尝试将正确的权限应用于上传文件夹,在大多数ftp浏览器中,右键单击文件夹&gt;文件属性或权限,并将它们设置为777。
通过SSH,这将是:chmod -Rf 777 foldername