0

我想使用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 ( )

请大家帮帮我我做错了什么?

4

1 回答 1

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'];

于 2013-08-22T13:35:56.833 回答