发布输入文件并在上传之前重命名

时间:2019-02-20 01:17:43

标签: php codeigniter post upload codeigniter-3

我在codeigniter form_open_multipart中有这种情况:

enter image description here

现在我要上传名称为“ Nome File”字段的文件

这是我的代码:

public function aggiungiDocumento(){
        $nomeFile = $this->input->post('nomeFile');
        echo $nomeFile;
        $document = $_FILES['document']['name'];
        echo $document;
        if($document=''){

        }
        else {
            echo getcwd() . "\n";
            $config['upload_path']='./aziende';
            echo $config['upload_path'];
            $config['allowed_types']='jpg|gif|png';
            $this->load->library('upload', $config);
            if(!$this->upload->do_upload('document')){
                echo "nope";
            }
            else{
                echo "yup";
                $config['file_name'] = $nomeFile;
                echo $config['file_name'];
                $document=$this->upload->data('file_name');
            }

        }

上传的工作带有附件的名称,而不是我发布的字段的nomeFile

对不起,英语:) 有人可以帮助我吗? 非常感谢

1 个答案:

答案 0 :(得分:0)

此代码放置不正确。

class Vividict(dict):
    def __missing__(self, key):
        value = self[key] = type(self)() # retain local pointer to value
        return value                     # faster to return than 
                                         # ...'dict lookup'

ydata = Vividict()

ydata["MC1"][123]["PP"] = "-15,-15C"
ydata["MC1"][456]["PP"] = "5,5C"
ydata["MC1"][391]["PP"] = "-19,-19C"
ydata["MC1"][287]["PP"] = "-12,-12C"

pprint.pprint(ydata)              # Ok, shows the full strucure

尝试一下

$config['file_name'] = $nomeFile;