【发布时间】:2012-01-09 03:23:50
【问题描述】:
大家好,希望大家能帮到我
问题是这样的,我有一个带有以下代码的表单:
<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!";
}
}
?>
问题是它没有给我错误,也没有上升到数据库或将图像上传到服务器上的文件夹。
我做错了什么?
谢谢你,希望你能帮助我
【问题讨论】:
-
没有收到任何错误消息?添加你自己的!使用调试语句跟踪代码以隔离问题。
-
这里似乎可以正常工作,尝试在
<?php之后添加error_reporting(E_ALL);并查看它是否会产生任何错误。另外,我注意到您正在将其上传到父文件夹 (../) 中的文件夹,应该是这样吗? -
你应该添加几个“断点”,在条件之前尝试 var_dump( $_FILES ),可能是文件夹权限的问题。
-
´警告:无法修改标头信息 - 标头已由 /home/sitios/public_html 中的(输出开始于 /home/sitios/public_html/farmland/farmland/ad5/uploadernoticias.php:3)发送/farmland/farmland/ad5/uploadernoticias.php 第 36 行'
-
该文件在 Ad5 uploader.php / 中并转到 images 文件夹 / 属性文件夹在 Ad5 之外 我的电脑工作正常!但由于我的域无法正常工作,请尝试将 .. /imagenes/noticias news 不带 /.我也有 error_reporting (E_ALL) 并且我得到错误