如何在codeigniter中上传图像 [英] how can upload image in codeigniter

查看:135
本文介绍了如何在codeigniter中上传图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

他尝试将图片上传到我的素材资源夹。但我不能做到正确。实际上我想保存的图像名称为最后插入的id
我不知道错误是什么。请帮助我

hey i am trying to upload an image into my assets folder . But i couldn't make it properly. actually i want to save the image with name as "last inserted id". i don't know what the mistake is. please help me

   $.ajax({
                url: base_url+"register/reg_submit/",
                data: $('#career_submit_form').serialize(),//returns all cells' data
                dataType: 'json',
                type: 'POST',
                success: function (res) {
                    alert(res.result)
   },

reg_submit

      $application_insert = $this->career->insert_student_application($personal_details,$parent_details,$other_details);

    $config['upload_path'] = './application/assets/images/user_image/';
    $config['allowed_types'] = 'jpg'; 
    $config['file_name'] = $application_insert.'.jpg'; 
    $this->load->library('upload', $config); 
    if (!$this->upload->do_upload('userfile'))
    {     
        echo $this->upload->display_errors();  

    } 


推荐答案

请按照以下步骤操作

1. check $application_insert variable return anything?

2. change './application/assets/images/user_image/' to "application/assets/images/user_image/"

3. make writable all the folders assests, images and user_image

4. check spelling of the folders are same what you given in the upload path

这篇关于如何在codeigniter中上传图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆