使用php和mysql上传多个文件?
大家好,我希望你们能帮助我 问题是,我有一个带有以下代码的表单:使用php和mysql上传多个文件?,php,mysql,file,upload,Php,Mysql,File,Upload,大家好,我希望你们能帮助我 问题是,我有一个带有以下代码的表单: <form action="uploadernoticias.php" method="post" enctype="multipart/form-data" name="form1" class="nice" id="form1"> <h2>Insertar Noticias</h2> <p class="left"> <label>Titu
<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!";
}
}
?>
问题是它不会给我任何错误,也不会上升到数据库或将图像上载到服务器上的文件夹
我做错了什么
谢谢,希望您能帮助我也许您没有目标路径的写入权限。你检查过了吗?可能您没有看到任何错误消息,因为您禁用了display_errors(在php.ini中)。您可以在服务器中激活显示错误或激活日志记录: 如果您无权访问配置文件,可以在脚本中尝试以下操作:
ini_set('display_errors','On');
可能您在目标路径中没有写入权限。你检查过了吗?可能您没有看到任何错误消息,因为您禁用了display_errors(在php.ini中)。您可以在服务器中激活显示错误或激活日志记录: 如果您无权访问配置文件,可以在脚本中尝试以下操作:
ini_set('display_errors','On');
尝试对上载文件夹应用正确的权限,在大多数ftp浏览器中,右键单击文件夹>文件属性或权限,并将其设置为777。
通过SSH,这将是:
chmod-Rf 777 foldername
尝试对上载文件夹应用正确的权限,在大多数ftp浏览器中,右键单击文件夹>文件属性或权限,并将其设置为777。
通过SSH,这将是:
chmod-Rf 777 foldername
没有收到任何错误消息吗?添加你自己的!使用调试语句跟踪代码以隔离问题。在这里似乎工作正常,请尝试添加error\u reporting(E\u ALL)
在之后,您应该添加几个“断点”,在条件之前尝试var_dump($_文件),这可能是文件夹权限的问题。')警告:无法修改标题信息-标题已由发送(输出从/home/sitios/public_html/landlandlands/ad5/uploadernoticias.php:3开始)在第36行的/home/sitios/public_html/grands/grands/ad5/uploadernoticias.php中,文件位于ad5 uploader.php/中,并转到图像文件夹/properties文件夹,它位于ad5之外,我的计算机工作正常!但到目前为止,我的域名无法正常工作,请尝试将/不带/的imagenes/noticias新闻。此外,我有错误报告(E_ALL),我收到错误没有收到任何错误消息?添加你自己的!使用调试语句跟踪代码以隔离问题。在这里似乎工作正常,请尝试添加error\u reporting(E\u ALL)
在之后,您应该添加几个“断点”,在条件之前尝试var_dump($_文件),这可能是文件夹权限的问题。')警告:无法修改标题信息-标题已由发送(输出从/home/sitios/public_html/landlandlands/ad5/uploadernoticias.php:3开始)在第36行的/home/sitios/public_html/grands/grands/ad5/uploadernoticias.php中,文件位于ad5 uploader.php/中,并转到图像文件夹/properties文件夹,它位于ad5之外,我的计算机工作正常!但到目前为止,我的域名无法正常工作,请尝试将/不带/的imagenes/noticias新闻。此外,我有错误报告(E_ALL),我有错误,我设置了ini_集(“显示错误”,“打开”),现在没有给我任何错误,诊断问题需要更多的数据?此外,我设置了ini_集(“显示错误”,“打开”),现在没有给我任何错误,诊断问题需要更多的数据?