Joomla表单上的文件上传解析问题

时间:2018-09-11 15:17:13

标签: php jquery html forms joomla

简历上传解析页面出现问题:

http://ablcareers-dev.cloudaccess.host/search-abl-jobs/resume/013947为例

当用户单击以上传他们的简历并选择CONFIRM INFO时,页面将在几秒钟后刷新,并且似乎没有任何数据被处理。

代码如下,简单的文件上传和脚本。与Joomla合作。

<form class="uk-form"  name="frmMain" method="post" id="frmMain" enctype="multipart/form-data">
    <input type="hidden" name="jobId" value="<?= $this->jobID ?>" />
    <input type="hidden" name="email" value="<?= $this->email ?>" />
    <input type="hidden" name="action" value="resume" />
    <input class="form-control  uk-form-large uk-width-7-10" id="filResume1" type="file" name="filResume1" />
    <button class="uk-button-primary submit uk-button" >Confirm Info</button>
    <label class="error" for="filResume1"></label>
    <button class="noresume uk-button uk-button-primary" >I  don't have a resume</button>
    <p style="font-size:12px">No Resume? No Problem you can still apply manually</p>
    <p id="spProcessing"></p>
 </form>

<script>
    jQuery('.submit').click(function() {
        jQuery('#spProcessing').text('Processing resume ............... ');
        jQuery('#frmMain').submit();
    });
    jQuery('.noresume').click(function() {
        jQuery('#frmMain').submit();
    });
 </script>

控制台中没有错误,我无法弄清楚可能是问题的原因。

PHP / MySQL版本是否可能影响此功能?

function uploadParseResume(){
    $applicantId = $this->sendRequest(self::$serviceUrl ."/applicant");
    if ($applicantId === false)
        return false;

    $applicantId = str_replace('"', "", $applicantId);
    $resume1= $_FILES['filResume1']['tmp_name'];
    $resume2= $_FILES['filResume2']['tmp_name'];
    $resume3= $_FILES['filResume3']['tmp_name'];
    $resume4= $_FILES['filResume4']['tmp_name'];
    $resume5= $_FILES['filResume5']['tmp_name'];

    $tmpDir = dirname($_FILES['filResume1']['tmp_name']) . DIRECTORY_SEPARATOR;

    $target = $tmpDir . $_FILES["filResume1"]["name"];

    $post = array();

    if($resume1!=''){
        $file_name_with_full_path = realpath($target);
        move_uploaded_file( $_FILES['filResume1']['tmp_name'], $target);
        $post = array(
            'resume_name' => '@'.$file_name_with_full_path,
            'file_contents[0]'=>'@'.$file_name_with_full_path
        );

    }
    if($resume2!=''){
        $target2 = $tmpDir. $_FILES["filResume2"]["name"];
        move_uploaded_file( $_FILES['filResume2']['tmp_name'], $target2);
        array_push($post,'@'.realpath($target2),'file_contents[1]');
    }

    if($resume3!=''){
        $target3 = $tmpDir. $_FILES["filResume3"]["name"];
        move_uploaded_file( $_FILES['filResume3']['tmp_name'], $target3);
        array_push($post,'@'.realpath($target3),'file_contents[2]');
    }

    if($resume4!=''){
        $target4 = $tmpDir. $_FILES["filResume4"]["name"];
        move_uploaded_file( $_FILES['filResume4']['tmp_name'], $target4);
        array_push($post,'@'.realpath($target4),'file_contents[3]');
    }

    if($resume5!=''){
        $target5 = $tmpDir. $_FILES["filResume5"]["name"];
        move_uploaded_file( $_FILES['filResume5']['tmp_name'], $target5);
        array_push($post,'@'.realpath($target5),'file_contents[4]');
    }

    $result ="";

    $ch = curl_init();
    curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_URL, self::$serviceUrl . "/file/upload/?id=".$applicantId);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Basic " . self::$apiKey));

    curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    $result = curl_exec($ch);
    if($result  === false)
    {
        echo 'Curl error: ' . curl_error($ch) . '   ' . curl_errno($ch) . 
   '<br>';
    }


    curl_close($ch);
    $info = "";
    $workHistory = "";
    $applicantId = "";

    $firstName ="";
    $lastName = "";
    $phone = "";
    $mobile = "";
    $street = "";
    $city = "";
    $suite = "";
    $postalCode = "";
    $positionDesired = "";
    $website = "";
    $companyName1 ="";
    $startDate1 = "";
    $endDate1 = "";
    $title1 = "";
    $reason1 = "";
    $super1 = "";
    $phone1 = "";
    $payRate1 = "";
    $desc1 = "";    
    $companyName2 ="";
    $startDate2 = "";
    $endDate2 = "";
    $title2 = "";
    $reason2 = "";
    $super2 = "";
    $phone2 = "";
    $payRate2 = "";
    $desc2 = "";
    $companyName3 ="";
    $startDate3 = "";
    $endDate3 = "";
    $title3 = "";
    $reason3 = "";
    $super3 = "";
    $phone3 = "";
    $payRate3 = "";
    $desc3 = "";



    if($result!="")
    {

        $obj = json_decode($result);
        $info = $obj->{'info'};
        $applicantId = $info->{'applicantId'};
        $firstName = $info->{'firstName'};
        $lastName = $info->{'lastName'};
        $phone = $info->{'phone'};
        $mobile = $info->{'CellPhone'};
        $street = $info->{'street'};
        $city = $info->{'city'};
        $suite = $info->{'suite'};
        $postalCode = $info->{'postalCode'};
        $positionDesired = $info->{'positionDesired'};
        $website = $info->{'website'};
        $workHistory = $info->{'workHistory'};
        $companyName1 = $workHistory->{'companyName1'};
        $startDate1 = $workHistory->{'startDate1'};
        $endDate1 = $workHistory->{'endDate1'};
        $title1 = $workHistory->{'title1'};
        $reason1 = $workHistory->{'reason1'};
        $super1 = $workHistory->{'super1'};
        $phone1 = $workHistory->{'phone1'};
        $payRate1 = $workHistory->{'payRate1'};
        $desc1 = $workHistory->{'desc1'};
        $companyName2 = $workHistory->{'companyName2'};
        $startDate2 = $workHistory->{'startDate2'};
        $endDate2 = $workHistory->{'endDate2'};
        $title2 = $workHistory->{'title2'};
        $reason2 = $workHistory->{'reason2'};
        $super2 = $workHistory->{'super2'};
        $phone2 = $workHistory->{'phone2'};
        $payRate2 = $workHistory->{'payRate2'};
        $desc2 = $workHistory->{'desc2'};
        $companyName3 = $workHistory->{'companyName3'};
        $startDate3 = $workHistory->{'startDate3'};
        $endDate3 = $workHistory->{'endDate3'};
        $title3 = $workHistory->{'title3'};
        $reason3 = $workHistory->{'reason3'};
        $super3 = $workHistory->{'super3'};
        $phone3 = $workHistory->{'phone3'};
        $payRate3 = $workHistory->{'payRate3'};
        $desc3 = $workHistory->{'desc3'};

    }
    session_start();
//  $_SESSION['applicantId'] = $applicantId;
    $_SESSION['firstName'] = $firstName;
    $_SESSION['responsecode'] = $responsecode;
    $_SESSION['lastName'] = $lastName;
    $_SESSION['phone'] = $phone;
    $_SESSION['mobile'] = $mobile;
    $_SESSION['street'] = $street;
    $_SESSION['city'] = $city;
    $_SESSION['postalCode'] = $postalCode;
    $_SESSION['companyName1'] = $companyName1;
    $_SESSION['startDate1'] = $startDate1;
    $_SESSION['endDate1'] = $endDate1;
    $_SESSION['title1'] = $title1;
    $_SESSION['reason1'] = $reason1;
    $_SESSION['super1'] = $super1;
    $_SESSION['phone1'] = $phone1;
    $_SESSION['payRate1'] = $payRate1;
    $_SESSION['desc1'] = $desc1;
    $_SESSION['companyName2'] = $companyName2;
    $_SESSION['startDate2'] = $startDate2;
    $_SESSION['endDate2'] = $endDate2;
    $_SESSION['title2'] = $title2;
    $_SESSION['reason2'] = $reason2;
    $_SESSION['super2'] = $super2;
    $_SESSION['phone2'] = $phone2;
    $_SESSION['payRate2'] = $payRate2;
    $_SESSION['desc2'] = $desc2;
    $_SESSION['companyName3'] = $companyName3;
    $_SESSION['startDate3'] = $startDate3;
    $_SESSION['endDate3'] = $endDate3;
    $_SESSION['title3'] = $title3;
    $_SESSION['reason3'] = $reason3;
    $_SESSION['super3'] = $super3;
    $_SESSION['phone3'] = $phone3;
    $_SESSION['payRate3'] = $payRate3;
    $_SESSION['desc3'] = $desc3;
//  echo '<pre>';
//  print_r($obj);
//  echo $companyName1;
//  echo $street;
//  echo '</pre>';  

    return $applicantId;

任何见解都会有所帮助,

谢谢!

0 个答案:

没有答案