Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/289.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
输入类型中的函数=php中的文件_Php_Html_Mysql_Css - Fatal编程技术网

输入类型中的函数=php中的文件

输入类型中的函数=php中的文件,php,html,mysql,css,Php,Html,Mysql,Css,如何在php.Html代码中使用input type=file编写函数,而不使用echo语句t与将路径复制到textbox一样有效 <form name="profile" method="post" enctype="multipart/form-data"> <?php echo '<p style="margin-left:1cm"><input type="text" id="file2" size=18 maxlength=500

如何在php.Html代码中使用
input type=file
编写函数,而不使用
echo语句
t与将路径复制到textbox一样有效

  <form name="profile" method="post" enctype="multipart/form-data">
  <?php
      echo '<p style="margin-left:1cm"><input type="text" id="file2" size=18 maxlength=500><input type="file" name="bfile2" onchange="CopyMe(this, 'file2');" /></p>';
   ?>
 </form>

 <script>
function CopyMe(oFileInput, sTargetID) {
   document.getElementById(sTargetID).value = oFileInput.value;
}


您的问题在于此部分:

CopyMe(this, 'file2');
字符正在打断您的回音。 使用
\
对字符进行转义

因此,您的代码最终为:

echo '<p style="margin-left:1cm"><input type="text" id="file2" size=18 maxlength=500><input type="file" name="bfile2" onchange="CopyMe(this, \'file2\');" /></p>';
echo'


谢谢。它正在工作