在CodeIgniter中上传多张照片,可以通过以下步骤完成:
<form method="post" action="upload_handler" enctype="multipart/form-data">
<input type="file" name="photos[]" multiple>
<input type="submit" value="Upload">
</form>
public function upload_handler()
{
$photos = $_FILES['photos'];
$upload_path = '/path/to/upload/directory/';
foreach ($photos['tmp_name'] as $key => $tmp_name) {
$file_name = $photos['name'][$key];
$file_path = $upload_path . $file_name;
if (move_uploaded_file($tmp_name, $file_path)) {
// 上传成功
} else {
// 上传失败
}
}
}
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = 1024; // 限制文件大小为1MB
$this->load->library('upload', $config);
推荐的腾讯云相关产品:腾讯云对象存储(COS) 产品介绍链接地址:https://cloud.tencent.com/product/cos
领取专属 10元无门槛券
手把手带您无忧上云