Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/413.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
Javascript php文件未在ajax序列化中上载_Javascript_Php_File Upload - Fatal编程技术网

Javascript php文件未在ajax序列化中上载

Javascript php文件未在ajax序列化中上载,javascript,php,file-upload,Javascript,Php,File Upload,这是我的HTML <form class="form form-vertical captcha_from" style="width: 50%;" method="post" action="<?php echo base_url('home/post_job_save'); ?>" enctype = "multipart/form-data"> <div class="container"> <div cl

这是我的HTML

<form class="form form-vertical captcha_from" style="width: 50%;" method="post" action="<?php echo base_url('home/post_job_save'); ?>" enctype = "multipart/form-data">
        <div class="container">

            <div class="row form-group">
                <div class="col-xs-12">
                    <ul class="nav nav-pills nav-justified thumbnail setup-panel">
                        <li class=""><a href="#step-1">
                            <h4 class="list-group-item-heading">Add Profile</h4>
                            <p class="list-group-item-text">First Step</p>
                        </a></li>
                        <li class=""><a href="#step-2">
                            <h4 class="list-group-item-heading">Add Resume</h4>
                            <p class="list-group-item-text">Second Step</p>
                        </a></li>
                        <li class=""><a href="#step-3">
                            <h4 class="list-group-item-heading">Add Cover Letter</h4>
                            <p class="list-group-item-text">Third Step</p>
                        </a></li>

                        <li class="active"><a href="#step-4">
                            <h4 class="list-group-item-heading">Add Photo</h4>
                            <p class="list-group-item-text">Fourth Step</p>
                        </a></li>

                    </ul>
                </div>
            </div>
            <div class="row setup-content" id="step-1" >
                <div class="col-xs-12">
                    <div class="col-md-12 well">
                        <h1>Add Profile</h1>

                            <div class="container">
                                <div class="row clearfix">
                                    <div class="col-md-12 column">
                                        <div class="control-group">
                  <label>First Name*</label>
                  <div class="controls">
                    <input type="text" class="form-control" placeholder="First Name" name="first_name" required="">
                  </div>
                </div>

                <div class="control-group">
                  <label>Last Name*</label>
                  <div class="controls">
                    <input type="text" class="form-control" placeholder="last Name" name="last_name" required="">
                  </div>
                </div>

                <div class="control-group">
                  <label>Email*</label>
                  <div class="controls">
                    <input type="email" class="form-control" placeholder="Email" name="email" required="">
                  </div>
                </div>
            </div>
        </div>
    </div>
                    </div>
                </div>
            </div>

    <div class="row setup-content" id="step-2">
        <div class="col-xs-12">
            <div class="col-md-12 well">
                <h1 class="text-center">Add Resume</h1>
                <div class="container">
                      <div class="row">
                        <div class="col-lg-12">
                            <div class="form-group">
                                <label for="file">Select a file to upload</label>

                                <input type="file" name="resume">
                                <p class="help-block">Only jpg,jpeg,png and gif file with maximum size of 1 MB is allowed.</p>
                            </div>
                        </div>
                      </div>
                </div><!-- /container -->

            </div>
        </div>
    </div>

    <div class="row setup-content" id="step-3">
        <div class="col-xs-12">
            <div class="col-md-12 well">
                <h1 class="text-center">Add Cover Letter</h1>
                      <div class="form-group">
                        <label for="file">Select a file to upload</label>
                        <input type="file" name="cover_letter">
                        <p class="help-block">Only jpg,jpeg,png and gif file with maximum size of 1 MB is allowed.</p>
                      </div>

            </div>
        </div>
    </div>

    <div class="row setup-content" id="step-4">
        <div class="col-xs-12">
            <div class="col-md-12 well">
                <h1 class="text-center">Add Photo</h1>
                      <div class="form-group">
                        <label for="file">Select a file to upload</label>
                        <input type="file" name="photo">
                        <p class="help-block">Only jpg,jpeg,png and gif file with maximum size of 1 MB is allowed.</p>
                      </div>
                      <input type="submit" id="apply_job_save_submit" class="btn btn-primary btn-md" value="Submit">
            </div>
        </div>

    </div>

</div></form>
php代码:

if(isset($_FILES) && $_FILES["resume"]["name"]!=''){
                $org_filename=$_FILES["resume"]["name"];
                $arr=explode('.', $org_filename);
                $filename='resume'.time().'.'.$arr[count($arr)-1];
                $target_dir = UPLOAD_PATH;
                $target_file = $target_dir . basename($filename);
                move_uploaded_file($_FILES["resume"]["tmp_name"], $target_file);

                $_POST['resume']=$filename;
            }

            if(isset($_FILES) && $_FILES["cover_letter"]["name"]!=''){
                $org_filename=$_FILES["cover_letter"]["name"];
                $arr=explode('.', $org_filename);
                $filename='cover_letter'.time().'.'.$arr[count($arr)-1];
                $target_dir = UPLOAD_PATH;
                $target_file = $target_dir . basename($filename);
                move_uploaded_file($_FILES["cover_letter"]["tmp_name"], $target_file);

                $_POST['cover_letter']=$filename;
            }

            if(isset($_FILES) && $_FILES["photo"]["name"]!=''){
                $org_filename=$_FILES["photo"]["name"];
                $arr=explode('.', $org_filename);
                $filename='photo'.time().'.'.$arr[count($arr)-1];
                $target_dir = UPLOAD_PATH;
                $target_file = $target_dir . basename($filename);
                move_uploaded_file($_FILES["photo"]["tmp_name"], $target_file);

                $_POST['photo']=$filename;
            }
$this->general_model->insert('apply_job',$_POST);
使用这段代码,我尝试将一些数据发送到我的数据库中,并使用post方法将文件上载到我的服务器中。所有数据都已发布,但文件未上载。 上载文件时显示错误 未定义索引:恢复 未定义索引:封面信 未定义索引:照片 如何解决这个问题

未定义索引:恢复
未定义索引:封面字母
未定义索引:照片


这意味着$\u FILES数组中没有此类记录,这反过来意味着文件未上载。这是因为这些文件的内容在表单序列化时没有被提取。有关解决方案,请参阅。

关于如何通过ajax上传文件的示例有几十个,如果不是几百个,也有几十个。你检查过他们吗?如果您这样做了,您会发现您需要在客户端添加更多的代码和设置,以使其正常工作。
if(isset($_FILES) && $_FILES["resume"]["name"]!=''){
                $org_filename=$_FILES["resume"]["name"];
                $arr=explode('.', $org_filename);
                $filename='resume'.time().'.'.$arr[count($arr)-1];
                $target_dir = UPLOAD_PATH;
                $target_file = $target_dir . basename($filename);
                move_uploaded_file($_FILES["resume"]["tmp_name"], $target_file);

                $_POST['resume']=$filename;
            }

            if(isset($_FILES) && $_FILES["cover_letter"]["name"]!=''){
                $org_filename=$_FILES["cover_letter"]["name"];
                $arr=explode('.', $org_filename);
                $filename='cover_letter'.time().'.'.$arr[count($arr)-1];
                $target_dir = UPLOAD_PATH;
                $target_file = $target_dir . basename($filename);
                move_uploaded_file($_FILES["cover_letter"]["tmp_name"], $target_file);

                $_POST['cover_letter']=$filename;
            }

            if(isset($_FILES) && $_FILES["photo"]["name"]!=''){
                $org_filename=$_FILES["photo"]["name"];
                $arr=explode('.', $org_filename);
                $filename='photo'.time().'.'.$arr[count($arr)-1];
                $target_dir = UPLOAD_PATH;
                $target_file = $target_dir . basename($filename);
                move_uploaded_file($_FILES["photo"]["tmp_name"], $target_file);

                $_POST['photo']=$filename;
            }
$this->general_model->insert('apply_job',$_POST);