Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/72.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_Jquery_Html - Fatal编程技术网

Php 文件未上载到同一服务器中的另一个目录。?

Php 文件未上载到同一服务器中的另一个目录。?,php,jquery,html,Php,Jquery,Html,我想将文件上载到word press目录之外的另一个目录 这是我的HTML <form> <div class="form-group upload-btn-wrapper2"> <span id="">Member Passport - Front</span> <input required="" type="file" dir="rtl" name="member_passport_front_copy_names" id="memb

我想将文件上载到word press目录之外的另一个目录

这是我的HTML

<form>
<div class="form-group  upload-btn-wrapper2">
<span id="">Member Passport - Front</span>
<input required="" type="file" dir="rtl" name="member_passport_front_copy_names" id="member_passport_front_copy_names" class="form-control valid" for="UAE citizen" aria-required="true" aria-invalid="false">
</div>

</form>

当我更改或上载文件时,它会给出成功响应,但文件不会上载到目录。

move\u upload\u file
不适用于HTTP URL–您需要为目标指定文件系统路径


相对于脚本的当前工作目录,或者作为服务器文件系统根目录的完整绝对路径。

很可能无法正常工作。尝试检查此函数的结果。是否检查了错误日志?
move\u upload\u file
不适用于HTTP URL,您需要指定文件系统路径。(如果您不知道这两者之间的区别,请首先阅读。)@misorude应该使用../../../../../../../../.或者使用服务器根目录的完整本地文件系统路径。
   jQuery(document).ready(function () {

                jQuery('body').on('change', '#member_passport_front_copy_names', function (evt) {

                         var data = new FormData(this.form);
                          var data = new FormData();
        var files = jQuery('#member_passport_front_copy_names')[0].files[0];
        data.append('file',files);
                         jQuery.ajax({
                             url: '<?php echo site_url(); ?>/wp-admin/admin-ajax.php?action=cms_filesubmit',
                             type: "POST",
                             data: data,
                            mimeType: "multipart/form-data",
                            contentType: false,
                             processData: false,
                            cache: false,
                            dataType: "html",
                             success: function (response) {
                                  console.log(response);

                             },
                             error: function (response) { 
                             alert("something went wrong");
                             }
                         });


            });
                }); 
add_action( 'wp_ajax_cms_filesubmit', 'cms_filesubmit' );
add_action( 'wp_ajax_nopriv_cms_filesubmit', 'cms_filesubmit' );

function cms_filesubmit(){

$target_dir = "http://sajaya.ae/himmah/app/webroot/img/user_upload/";

if(isset($_FILES['file'])){
      $errors= array();
      $file_name = $_FILES['file']['name'];
      $file_size =$_FILES['file']['size'];
      $file_tmp =$_FILES['file']['tmp_name'];
      $file_type=$_FILES['file']['type'];
      $file_ext=strtolower(end(explode('.',$_FILES['file']['name'])));

      $extensions= array("jpeg","jpg","png");

      if(in_array($file_ext,$extensions)=== false){
         $errors[]="extension not allowed, please choose a JPEG or PNG file.";
      }

      if($file_size > 2097152){
         $errors[]='File size must be excately 2 MB';
      }

      if(empty($errors)==true){
         move_uploaded_file($file_tmp,"http://sajaya.ae/himmah/app/webroot/img/user_upload/".$file_name);
         echo "Success";
      }else{
         print_r($errors);
      }
   }
}