我有一个表单,我在其中发布不同的字段,并且除了输入文件类型之外,发布的每种类型的字段似乎都有效。
我正在使用 var_dump($_POST);
并且所有其他字段都在那里,但输入类型文件中没有任何字段。
我的表单部分如下所示:
<form enctype="multipart/form-data" id="ajax-form" action="index2.php" method="POST" data-ajax="true">
并且适用于其他一切。
输入类型文件中有什么不同吗?
<input type="text" id="myid" name="myid" value="" /> ..This posts value
<input id="theimage" name="theimage" type="file" /> .. does not post value
大家有什么想法吗?
最佳答案
文件存储在$_FILES中,而不是$_POST
http://php.net/manual/en/reserved.variables.files.php $_FILES 变量
http://www.php.net/manual/en/features.file-upload.php PHP 文件上传手册。
处理文件(不进行错误检查):
$ROOT = "/path/to/store/files";
foreach($_FILES as $file => $details)
{ // Move each file from its temp directory to $ROOT
$temp = $details['tmp_name'];
$target = $details['name'];
move_uploaded_file($temp, $ROOT.'/'.$target);
}
另请参阅http://www.php.net/manual/en/function.move-uploaded-file.php了解更多示例。
关于php - 发布输入类型文件问题 未发布任何值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50118787/