Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/179.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
Wordpress插件开发-上传xml和parce_Wordpress_Wordpress Plugin Creation - Fatal编程技术网

Wordpress插件开发-上传xml和parce

Wordpress插件开发-上传xml和parce,wordpress,wordpress-plugin-creation,Wordpress,Wordpress Plugin Creation,我在我的自定义插件中找不到如何上传和保存文件的任何信息。我下一步就试了 <div class="dashboard-products-available"> <div class="dashboard-products-available__row"> <aside class="dashboard-products-available__aside col"> <div

我在我的自定义插件中找不到如何上传和保存文件的任何信息。我下一步就试了

<div class="dashboard-products-available">
  <div class="dashboard-products-available__row">
    <aside class="dashboard-products-available__aside col">
      <div class="dashboard-products-available__form">
        <form action="<?php echo $_SERVER["PHP_SELF"] . '?page=products-available'; ?>" method="post" enctype="multipart/form-data">
          <input type="file" name="file" id="file">
          <input type="submit" value="Send">
        </form>
      </div>
    </aside>
  </div>
</div>


<?php
var_dump($_POST);
if ( isset($_POST["submit"]) ) {

  if ( isset($_FILES["file"])) {

    //if there was an error uploading the file
    if ($_FILES["file"]["error"] > 0) {
      echo "Return Code: " . $_FILES["file"]["error"] . "<br />";

    }
    else {
      //Print file details
      echo "Upload: " . $_FILES["file"]["name"] . "<br />";
      echo "Type: " . $_FILES["file"]["type"] . "<br />";
      echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
      echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";

      //if file already exists
      if (file_exists("upload/" . $_FILES["file"]["name"])) {
        echo $_FILES["file"]["name"] . " already exists. ";
      }
      else {
        //Store file in directory "upload" with the name of "uploaded_file.txt"
        $storagename = "uploaded_file.txt";
        move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $storagename);
        echo "Stored in: " . "upload/" . $_FILES["file"]["name"] . "<br />";
      }
    }
  } else {
    echo "No file selected <br />";
  }
}
?>