【问题标题】:How to get the name of uploaded file on server如何在服务器上获取上传文件的名称
【发布时间】:2023-03-11 18:30:01
【问题描述】:

我使用CodeIgniter的“文件上传类”上传文件;我的问题是稍后我使用上传的图像名称,虽然我已经使用以下代码来给出全名的含义,但用户可能已经保存了相同的名称,新文件将类似于“John1”、“John2” , "John3",...

        ...
        $config['file_name'] = $this->input->post("employeeName");
        $this->load->library('upload', $config);

有没有什么方法可以找出用于保存添加了扩展名的文件的真实姓名?

我希望我的问题很清楚,但如果您需要更多澄清,请告诉我您需要更多澄清的部分。

谢谢

【问题讨论】:

    标签: php codeigniter


    【解决方案1】:

    $this->upload->data() 将在文件上传后返回一个包含文件所有内容的 assoc 数组:

    样本输出:

    Array
    (
        [file_name]    => mypic.jpg
        [file_type]    => image/jpeg
        [file_path]    => /path/to/your/upload/
        [full_path]    => /path/to/your/upload/jpg.jpg
        [raw_name]     => mypic
        [orig_name]    => mypic.jpg
        [client_name]  => mypic.jpg
        [file_ext]     => .jpg
        [file_size]    => 22.2
        [is_image]     => 1
        [image_width]  => 800
        [image_height] => 600
        [image_type]   => jpeg
        [image_size_str] => width="800" height="200"
    )
    

    完整文档在这里:http://ellislab.com/codeigniter/user-guide/libraries/file_uploading.html

    【讨论】:

    • 谢谢你!你解决了!我必须等待 9 分钟才能接受您的解决方案 :)
    猜你喜欢
    • 2018-04-22
    • 1970-01-01
    • 1970-01-01
    • 2015-01-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-10
    相关资源
    最近更新 更多