-2

我已经多次上传文件,但不知道为什么这不起作用。在上传之前尝试做一个文件 desc 但 $HTTP_POST_FILES 和 $_FILES 似乎都不起作用。

  echo "Upload: " . $HTTP_POST_FILES["profilefilepic"]["name"] . "<br>";
  echo "Type: " . $HTTP_POST_FILES["profilefilepic"]["type"] . "<br>";
  echo "Size: " . ($HTTP_POST_FILES["profilefilepic"]["size"] / 1024) . " kB<br>";
  echo "Stored in: " . $HTTP_POST_FILES["profilefilepic"]["tmp_name"];


<form method="post" action="">
<input type="submit" name="changeorder" id="changeorder" value="Upload">
<input type="file" name="datafile" size="40" id="profilefilepic" name="profilefilepic">
<input type="hidden" name="profilefilepicname" id="profilefilepicname" value="">
</form>

这里有什么问题。

4

3 回答 3

6

添加enctype到您的表单

<form method="post" action="" enctype="multipart/form-data">

仅对输入文件类型使用一个name属性,例如:

<input type="file" name="profilefilepic" size="40" id="profilefilepic" />
于 2013-03-11T11:13:20.470 回答
2

您在输入中有 2 个“名称”属性,而您的表单中file缺少2 个“名称”属性。enctype

<form method="post" enctype="multipart/form-data">
<input type="file" id="profilefilepic" name="profilefilepic">
于 2013-03-11T11:17:01.713 回答
0

两件丢失的东西

  1. <input type="file" id="profilefilepic" name="profilefilepic">
  2. <form method="post" action="" enctype="multipart/form-data">

谢谢

Sudhir 和 Proreborn

于 2013-03-11T11:20:55.000 回答