zoukankan      html  css  js  c++  java
  • CI 图片上传路径问题的解决

     很久没有用CI了,新公司需要用ci ,图片上传的功能,我都搞半天,伤心

    1. 要看源码,upload.php里do_upload()是上传的主要函数。

    public function do_upload($field = 'userfile')
    	{
            //
            }
    

      默认name = 'userfile',这里要写你自己的name

    2.要测试,不能盲目的,盲目的以程序能否正确执行来判断

    // 图片上传
    			$config ['upload_path'] = 'data/flash';
    			$config ['allowed_types'] = 'gif|jpg|png';
    			$config ['max_size'] = '1024*2';
    			$config ['max_width'] = '1024';
    			$config ['max_height'] = '768';
    			// $config['encrypt_name'] = TRUE;
    			$this->load->library ( 'upload', $config );
    			
    			if (! $this->upload->do_upload ( 'imgUrl' )) {
    				$error = array (
    						'error' => $this->upload->display_errors () 
    				);
    			} else {
                       //图片相关信息都在这啦,你可以打印一下 $upload = $this->upload->data (); $time = time();
                       //图片上传到服务器后的间路径 $file1 = $config ['upload_path'].$upload ['raw_name'] . '.' . $upload ['image_type'];
                      //改成时间戳后的路径 $titleImg = $config ['upload_path'] . $time . '.' . $upload ['image_type'];
                       //直接rename() 当然我不知更好的方法,所以自己是这么解决的 rename($file1,$titleImg);
                      //将时间戳路径输出 $titleImg = base_url ( $config ['upload_path'].$time . '.' . $upload ['image_type']); }

      

  • 相关阅读:
    win10安装.net 3.5无法启动服务,原因可能是已被禁用或与其相关联的设备没有启动
    配置SQL用户访问指定表,指定列
    GNU Gettext for Delphi, C++ and Kylix
    Delphi 7 中使用IdUDPServer1和IdUDPClient1控件实现通信检测
    xp不能安装NET Framework4.0解决方法
    基于TCP的Socket连接【Delphi版】
    牛客网优惠码
    GitHub基本操作
    xdb-test
    设置本地yum源
  • 原文地址:https://www.cnblogs.com/linglingyang/p/4707264.html
Copyright © 2011-2022 走看看