wordpress管理中的自定义php表单

wordpress管理中的自定义php表单,php,forms,wordpress,Php,Forms,Wordpress,在这里,我用php制作了一个表单和动作文件,它可以完美地工作。然后我尝试在wordpress中实现它,表单显示良好,但当我提交它时,它不起作用。谁能帮帮我吗 //here is my html form <form action="<?php the_permalink(); ?>" method="post" enctype="multipart/form-data"> Please choose a file: <input type="file" name

在这里,我用php制作了一个表单和动作文件,它可以完美地工作。然后我尝试在wordpress中实现它,表单显示良好,但当我提交它时,它不起作用。谁能帮帮我吗

//here is my html form
<form action="<?php the_permalink(); ?>" method="post" enctype="multipart/form-data">
  Please choose a file: <input type="file" name="uploadFile"><br>
  <input type="submit" value="Upload File">
</form> 




and here is action area
<?php 
if(isset($_POST['submit'])) {
    $target_dir =  basename( $_FILES["uploadFile"]["name"]);
    $uploadOk=1;
    $contents2 = "";
    if (move_uploaded_file($_FILES["uploadFile"]["tmp_name"], $target_dir)) {
    echo "The file ". basename( $_FILES["uploadFile"]["name"]). " has been uploaded.";

    $CSVfp = fopen($target_dir, "r");
   if($CSVfp !== FALSE) 
   while(!feof($CSVfp)) {
   $data = fgetcsv($CSVfp, 3000, ",");
   $contents2 .=  $data[3]; 
   $var_str = var_export($contents2, true);
   $file = 'new_file.txt';
   $var_str = str_replace("'",",",$var_str);
   $var_str3 = ltrim($var_str,"Pin,");
   $var_str3 = implode(",", str_split($var_str3, 6))." ";
   $var_str4 = str_replace(",,","",$var_str3);
   file_put_contents($file, $var_str4);
} 

}
else {
    echo "Sorry, there was an error uploading your file.";
}

?> 
<form method="get" action="new_file.txt">
<button type="submit">Download!</button>
</form>
<?php
}

?>

你把这个表单放在哪里?没有更多的细节很难说,但是一个常见的“问题”是Wordpress仍然通过转义$u POST变量来复制旧的自动“添加斜杠”功能,这是PHP长期以来不推荐使用的功能。您的文件名可能因此被Wordpress弄乱,斜杠可能会导致文件名出现很多问题。有一个名为stripslashes\u deep的自定义函数,我会在所有$\u POST和$\u GET数据上自动运行,让我回到默认的PHP行为。有关详细信息,请参阅并注意,WordPress忽略内置的PHP magic quotes设置和get_magic_quotes_gpc的值,即使在5.4中从PHP中删除该功能后,也会始终添加magic quotes。我试图在同一页提交表单,因为在提交表单后我需要一些输出。但在这里,表单操作并不正常。有人知道怎么解决吗?在这里你可以看到实际发生了什么,这是我的网站的url。用户名是admin,密码是testwooc++。在左侧菜单栏上有一个标题为Upload COD File的管理菜单栏。我在当前主题的functions.php上添加了它,需要在同一页面上添加操作结果。但它不起作用。