php codeigniter中的图片上传错误[上传路径似乎无效。]

时间:2016-12-10 05:48:26

标签: php file-upload multipartform-data codeigniter-3 image-upload

我正在使用php codeigniter 2.x现在我将其更新为3.x,之后我的上传代码无效。 这是我的代码。请尽管它。 当此代码工作时总是收到错误

  

上传路径似乎无效。

$this->load->library('upload');
    $session = $this->ifisSession();
    $uploadfolder = 'profileImgs';

    $fullPath = 'abc';
    $imageconfig['upload_path'] = $fullPath;
    $imageconfig['max_size'] = (1024); // 1mb file size
    $imageconfig['allowed_types'] = 'gif|jpg|png';
    $imageconfig['max_width'] = (1024 );
    $imageconfig['max_height'] = (1024);
    $fieldName = 'profileimage';
    //$uploadfilename = $_FILES[$fieldName];
    $uploadfilename = $_FILES[$fieldName]['name'];
   // printv($uploadfilename, 'this ihere');

    $fileinfo = pathinfo($uploadfilename);

    if (isset($fileinfo['extension'])) {

        $ext = $fileinfo['extension'];
        $imageconfig['file_name'] = $session['firstname'] . '_' . $session['user_id_pk'] . '_' . uniqid() . '.' . $ext;
    }


    $this->load->library('upload', $imageconfig);

    if (!$this->upload->do_upload('profileimage')) {

        $error = $this->upload->display_errors();
        $data['data']['profileUpdate_error'] = $error;
        // move to profile page with erro message
    } else {

        $profileUploadinfo = array('upload_data' => $this->upload->data());
        $profileimgurl = '';
        $res = $this->Model_userinfo->updateProfileImg($session['user_id_pk'], $profileimgurl);
        if($res > 0){
            $data['data']['profileUpdate_success'] = 'Profile Updated';
        }else{
            $data['data']['profileUpdate_error'] = 'Profile Not updated';
        }
    }

0 个答案:

没有答案