Codeigniter image upload not working

前端 未结 2 2014
隐瞒了意图╮
隐瞒了意图╮ 2021-01-24 13:27

I can\'t get my images to upload no matter what i do. Below is the code that is in my model:

function do_upload()
{
    $config[\'upload_path\'] = \'./uploads/\'         


        
相关标签:
2条回答
  • 2021-01-24 14:03

    You can decrease the height and width of image which you are setting 1024 and 768.

    $config['max_width']  = '800';
    $config['max_height']  = '600';
    

    and secondly, I may suggest, you can store just the imagename say 'abc.jpg', not the entire path of the image. You don't need to store entire path in database because you can get this path by doing same when you were setting the path while uploading an image.

    0 讨论(0)
  • 2021-01-24 14:11

    Did something similar with a project - basically you just need to turn the path into a string and write it to your db...

    $fileup = $this->upload->data();
        $myfilepath = $fileup['file_name'];
        $databack = array(
            'your_field'=> 'http://www.yourserver.com/location/'.$myfilepath.'',
        ); 
        $DB->where('your_id_field', $id_value);
        $DB->update('your_table', $databack);  
    

    The trickiest bit is just tying it to your database!

    0 讨论(0)
提交回复
热议问题