Codeigniter multiple file upload messes file extension

后端 未结 5 1457
梦如初夏
梦如初夏 2020-11-29 22:41

I am trying to get a multiple upload library working for my Codeigniter based website. I have it working almost but I have a slight problem if I upload more than one image,

5条回答
  •  情歌与酒
    2020-11-29 23:01

    I was able to get multiple file uploads to work with clux's method but I had to modify the upload class slightly (I'm using Codeigniter 2). First I created a duplicate of the CI upload class into my applications library.

    Line 143:

    public function do_upload($field = 'userfile')
    

    change to

    public function do_upload($field = 'userfile', $i = 0)
    

    And between lines 160 and 200, you must add [$i] to the end of the $_FILES variables.

    Example:

    is_uploaded_file($_FILES[$field]['tmp_name'])
    

    change to:

    is_uploaded_file($_FILES[$field]['tmp_name'][$i])
    

    I believe there is a total of 9 of them.

提交回复
热议问题