无法用php发布数据

时间:2013-08-22 13:32:43

标签: php html post

我想使用PHP forms发布一些数据。为此我创建了一个表单如下:

    <form method="post" action="uploadimage.php" id="FileUploader" enctype="multipart/form-data">
         <div class="control-group">
            <label class="control-label" for="file">Upload Image</label>
            <div class="controls">
<input type="text" id="Fifle" name="name" />
              <input type="file" id="File" name="mFile" />
            </div>
          </div>
          <input type="submit" class="btn btn-info" name="submit" value="Upload" />
          </form>
我正在写uploadimage.php中的

<?php
$UploadDirectory    = 'upload/'; //Upload Directory, ends with slash & make sure folder exist

$MySql_username     = "root"; //mysql username
$MySql_password     = ""; //mysql password
$MySql_hostname     = "localhost"; //hostname
$MySql_databasename = 'mydb'; //databasename


if (!@file_exists($UploadDirectory)) {
    //destination folder does not exist
    die("Make sure Upload directory exist!");
}
print_r($_POST);

但是当我试图发帖时,它正在返回Array ( )

请各位帮助我,我做错了什么?

1 个答案:

答案 0 :(得分:0)

var_dump您将看到已发布的文件详情。

var_dump($_FILES['mFile']);

输出

array (size=5)
  'name' => string 'test.jpg' (length=41)
  'type' => string 'image/jpeg' (length=10)
  'tmp_name' => string 'C:\wamp\tmp\php335.tmp' (length=22)
  'error' => int 0
  'size' => int 29678

获取echo $_FILES['mFile']['name'];