Codeigniter 3.0:上传后文件名不会改变

时间:2017-10-01 07:54:03

标签: php codeigniter-3

我正在通过表单上传图片和文件。但上传后名称没有变化。在第一个函数调用时,如果名称是profilePic,那么即使我在$ config ['file_name']参数中更改名称,此文件名在每次调用时都保持相同。

函数调用:

package main

import (
    "fmt"
)

func main() {
    _inChannel := _inListener(generator())
    for val := range _inChannel {
        fmt.Print(val, " -- ")
    }
}

func generator() chan int { // NEED TO CALCULATE FACTORIAL FOR 100 NUMBERS
    ch := make(chan int) // CREATE CHANNEL TO INPUT NUMBERS

    go func() {
        for i := 1; i <= 100; i++ {
            ch <- i
        }
        close(ch) // CLOSE CHANNEL WHEN ALL NUMBERS HAVE BEEN WRITTEM
    }()

    return ch
}

func _inListener(ch chan int) chan int {
    rec := make(chan int) // CHANNEL RECEIVED FROM GENERATOR
    go func() {
        for num := range ch { // RECEIVE THE INPUT NUMBERS FROM GENERATOR
            result := factorial(num) // RESULT IS A NEW CHANNEL CREATED
            rec <- <-result // MERGE INTO A SINGLE CHANNEL; rec
            close(result)
        }
        close(rec)
    }()
    return rec // RETURN THE DEDICATED CHANNEL TO RECEIVE ALL OUTPUTS
}

func factorial(n int) chan int {
    ch := make(chan int) // MAKE A NEW CHANNEL TO OUTPUT THE RESULT 
    // OF FACTORIAL
    total := 1
    for i := n; i > 0; i-- {
        total *= i
    }
    ch <- total
    return ch // RETURN THE CHANNEL HAVING THE FACTORIAL CALCULATED
}

//上传功能

    function getAndSaveEmployeeDetails() {
    $resume = 'resume';
    $resume = $this -> do_upload($resume, $employeeID);

    $profilePic = 'profilePic';
    $profilePic = $this -> do_upload($profilePic, $employeeID);

    $cnic = 'cnicScannedImage';
    $cnicScannedImage = $this -> do_upload($cnic, $employeeID); }

请查看以下链接中的图片,了解行为

These are the file names and it is caching the first name passed in function call

1 个答案:

答案 0 :(得分:3)

使用

upload的第一行加载getAndSaveEmployeeDetails()

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

没有传递任何配置。

然后在定义配置数组后的do_upload($uploadedField, $employeeID)函数中,不要使用$this->load->library('upload', $config); 但请使用$this->upload->initialize($config);