为什么$ _FILES ['file'] ['name']!isset?

时间:2016-12-05 04:29:53

标签: php file

所以我想创建一个文件上传页面。我上传的所有文件都有一个非常小的尺寸,所以我相信它不是因为尺寸: upload.php的:

<?php
function upload(){
  if(isset($_POST['upload'])){
    if (isset($_FILES["file"]["name"])) {

    echo $name = $_FILES["file"]["name"];
    echo $tmp_name = $_FILES['file']['tmp_name'];
    echo $error = $_FILES['file']['error'];
  }else{
    echo "error";
  }
  }
  echo '      <div class="row pad">
        <div class="col-lg-3">
        </div>
        <div class="col-lg-6">
        <div class="login-form-1">
            <form id="register-form" class="text-left" method="post">
                <div class="login-form-main-message"></div>
                <div class="main-login-form">
                    <div class="login-group">
                        <div class="form-group">
                            <label for="new folder" class="sr-only">New file</label>
                            <input type="file" class="form-control" id="file" name="file" placeholder="upload file">
                  <p class="error">';if(isset($error)){ echo $error;}echo '</p>
                  <p class="success">';if(isset($message)){ echo $message;}echo'</p>
                        </div>
                <div class="move">
                    <input type="submit" class="button btn btn-primary" value="upload" name="upload">
                </div>
          </div>
      </div>
            </form>
        </div>
      </div>
      <div class="col-lg-3">
      </div>
    </div>';
}

?>

每次我收到“错误”。有谁知道为什么? 我知道这个表格有很多无用的div我会在最后处理那些

0 个答案:

没有答案