Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用iframe的target属性将表单发布到php脚本_Php_Html_Forms_Iframe - Fatal编程技术网

使用iframe的target属性将表单发布到php脚本

使用iframe的target属性将表单发布到php脚本,php,html,forms,iframe,Php,Html,Forms,Iframe,我正在从事一个php/HTMLWeb项目,我有一个表单,其中包含一个输入类型文件,该文件应该发布到php脚本中,以便将图像上传到服务器上。在form标记中,我使用target属性将iframe作为目标,这样它就可以模拟AJAX风格的post,也就是说,它将post发送到iframe,这样iframe就可以在不需要刷新主页的情况下完成工作 下面是我正在使用的表单 <form method="post" action="phpHandler/image-uploader.php" ta

我正在从事一个php/HTMLWeb项目,我有一个表单,其中包含一个输入类型文件,该文件应该发布到php脚本中,以便将图像上传到服务器上。在form标记中,我使用target属性将iframe作为目标,这样它就可以模拟AJAX风格的post,也就是说,它将post发送到iframe,这样iframe就可以在不需要刷新主页的情况下完成工作

下面是我正在使用的表单

    <form method="post" action="phpHandler/image-uploader.php" target="image_upload_frame">
<table>
    <tr>
       <td>
          Image Title:
       </td>
       <td>
         <input type="text" id="txtImageTitle" name="txtImageTitle" />
      </td>
   </tr>
   <tr>
     <td>
         Image File:
     </td>
     <td>
         <input type="file" id="txtImageFile" name="txtImageFile" />
     </td>
   </tr>
</table>
正在执行PHP脚本,但$\u文件和$\u POST数组为空

我尝试更改iframe以包含指向php脚本的src属性,并从表单中删除了该操作,但这似乎甚至没有执行php脚本

谢谢你能提供的帮助

添加

enctype="multipart/form-data"


谢谢,真不敢相信我忘了。谢谢,真不敢相信我忘了。
echo "posting";
    $title = $_POST['txtImageTitle'];
    $tempName = $_FILES['txtImageFile']['name'];

    writeToLog("Image Title:" . $title);
    writeToLog("Temp Name: $tempName\n");

    $data = var_export($_POST, true);
    $fileData = var_export($_FILES, true);

    writeToLog($data);
    writeToLog($fileData);

    function writeToLog($message)
    {
        $fh = fopen('log.txt', 'a');
        fwrite($fh, $message);
        fclose($fh);
    }
enctype="multipart/form-data"
 <form method="post" action="phpHandler/image-uploader.php" target="image_upload_frame">