将图像上载到CodeIgniter中的另一个目录

问题描述 投票:0回答:2

是否可以将图像上传到CodeIgniter中默认上传/缩略图目录以外的任何位置?我们在根目录中有我们的表单,但我们希望将照片发送到上传/拇指在另一个目录中。

例如,当前上传位置:www.mysite.com/upload/thumb/

我们希望从这里的`www.mysite.com/123/upload/thumb/根目录发送文件

我已经更改了控制器文件中的上传路径......无济于事。还有什么应该改变?谢谢!

image codeigniter file-upload directory
2个回答
1
投票

Read the docs。您可以使用config数组中的upload_path键设置它:

$config['upload_path']   = './123/upload/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size']      = '100';
$config['max_width']     = '1024';
$config['max_height']    = '768';

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

0
投票

设置源路径(保存文件的位置)

$sourcePath = $_FILES['userImage']['tmp_name'];

设置目标路径(这是你想去的地方)

$targetPath = "../cs/upload/thumb/".$_FILES['userImage']['name']; 

移动文件

move_uploaded_file($sourcePath,$targetPath)
© www.soinside.com 2019 - 2024. All rights reserved.