PHP表单在线发送空数据,但在本地主机上工作良好



我在PHP中得到了一些表单,所以我可以将数据上传到mysql数据库,我已经用xampp在本地主机服务器上进行了试验,但是当我将文件上传到我的主机FTP表单不起作用时,所以,我认为这与我将此文件和"connect.php"放在密码限制下的事实有关,,也与文件权限但是我已经授予权限的用户数据库和许可文件并没有密码保护的事情,我也试过,什么都没有,总是有相同的结果,所以我开始实验,我发现图像上传好到数据库中,但其他的不行,知道我试图"回声"其他输入结果但不显示,我得出的结论是,我的表格正在发送空数据,有人可以告诉我,如果我是对的吗?为什么会这样!请帮忙,这是我的代码…

<html>
<head>
<meta charset="UTF-8">
  <title>Untitled Document</title>
</head>
<body>
<div id="slider_upload">
<h1>Slider principal</h1>
    <div class="forma">
    <form action="sliderPrincipal.php" method="post" enctype="multipart/form-data">
        <p><label for="encabezado">Encabezado</label>
        <input type="text" id="encabezado" name="encabezado" /></p><br>
        <input type="hidden" name="MAX_FILE_SIZE" value="1048576" />
        <p><label for="fileupload">File to upload</label>
        <input type="file" id="fileupload" name="fileupload" /></p><br>
        <p><label for="articulo">Articulo</label>
        <textarea id="articulo" name="articulo" rows="26" style="width: 100%;" >Escribir aqui</textarea></p><br>
         <button type="submit" name="submit" value"send">Upload File</button>
    </form><br><br>
</div>
</div>
<div class="message">
    <?php 

$file_dir = "../uploaded";
if (isset($_POST['encabezado'])){
$encabezado = mysql_real_escape_string($_POST['encabezado']);
$articulo = mysql_real_escape_string($_POST['articulo']);
}

foreach($_FILES as $file_name => $file_array){
   //echo "path: ".$file_array['tmp_name']."<br />n";
   //echo "name: ".$file_array['name']."<br/>n";
   //echo "type: ".$file_array['type']."<br/>n";
   //echo "size: ".$file_array['size']."<br/><br/>n";
   //echo "encabezado ".$encabezado;
        if(is_uploaded_file($file_array['tmp_name'])){
        move_uploaded_file($file_array['tmp_name'], "$file_dir/".$file_array['name']) or die ("Your image couldnt be uploaded <br>");   
        $newpath = addslashes("uploaded/".$file_array['name']);
        include "connect.php"; 
        $addfile = "INSERT INTO slider (encabezado, image, articulo) VALUES ('$encabezado','$newpath', '$articulo')"; 
        $result = mysql_query($addfile);
        if ( $result === FALSE ) {
            echo "your post could not be uploaded but we already got your image in our files ";
        } else{
            echo '<p style="padding: 20px;"><h1>Your post was successfully uploaded <h2></p><br><br>';
        }

        mysql_close();  
    } else "No file found";

 }
 ?>
</div>  
</div>
</body>
</html>
$file_dir = "../uploaded";
if($_REQUEST['submit']) {
    $encabezado = mysql_real_escape_string($_POST['encabezado']);
    $articulo = mysql_real_escape_string($_POST['articulo']);
    foreach($_FILES as $file_name => $file_array){
        if(is_uploaded_file($file_array['tmp_name'])){
            move_uploaded_file($file_array['tmp_name'], "$file_dir/".$file_array['name']) or die ("Your image couldnt be uploaded <br>");   
            $newpath = addslashes("uploaded/".$file_array['name']);
            include "connect.php"; 
            $addfile = "INSERT INTO slider (`encabezado`, `image`, `articulo`) VALUES ('$encabezado','$newpath', '$articulo')"; 
            $result = mysql_query($addfile);
            if ( $result === FALSE ) {
                echo "your post could not be uploaded but we already got your image in our files ";
            } else{
                echo '<p style="padding: 20px;"><h1>Your post was successfully uploaded <h2></p><br><br>';
            }
        mysql_close();  
        } else "No file found";

 }
}

试试上面的代码。

相关内容

  • 没有找到相关文章

最新更新