Php 多文件上传-如何集成所有上传文件的缩略图功能?
这是我多个上传文件的代码 请你能帮助我与代码交换,也有缩略图集成Php 多文件上传-如何集成所有上传文件的缩略图功能?,php,file,codeigniter,file-upload,image-uploading,Php,File,Codeigniter,File Upload,Image Uploading,这是我多个上传文件的代码 请你能帮助我与代码交换,也有缩略图集成 public function addimage($room_id) { $name_array = array(); $count = count($_FILES['userfile']['size']); foreach($_FILES as $key=>$value) for($s=0; $s<=$count-1; $s++) { $_FILES['userfil
public function addimage($room_id)
{
$name_array = array();
$count = count($_FILES['userfile']['size']);
foreach($_FILES as $key=>$value)
for($s=0; $s<=$count-1; $s++) {
$_FILES['userfile']['name']=$value['name'][$s];
$_FILES['userfile']['type'] = $value['type'][$s];
$_FILES['userfile']['tmp_name'] = $value['tmp_name'][$s];
$_FILES['userfile']['error'] = $value['error'][$s];
$_FILES['userfile']['size'] = $value['size'][$s];
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png|jpeg';
//$config['encrypt_name'] = uniqid(date(1));
// $config['max_size'] = '100';
// $config['max_width'] = '1024';
// $config['max_height'] = '768';
$this->load->library('upload', $config);
$this->upload->do_upload();
$data = $this->upload->data();
$name_array[] = $data['file_name'];
} // end foreach
$names= array($name_array);
print_r($names);
exit();
公共功能附加图像($room\u id)
{
$name_array=array();
$count=计数($_文件['userfile']['size']);
foreach($\文件为$key=>$value)
对于($s=0;$sload->library('upload',$config));
$this->upload->do_upload();
$data=$this->upload->data();
$name_数组[]=$data['file_name'];
}//结束foreach
$names=数组($name\u数组);
打印(姓名);
退出();
这个怎么样
public function addimage($room_id)
{
$this->load->library("image_lib");
$name_array = array();
$count = count($_FILES['userfile']['size']);
foreach($_FILES as $key=>$value)
for($s=0; $s<$count; $s++) {
$_FILES['userfile']['name']=$value['name'][$s];
$_FILES['userfile']['type'] = $value['type'][$s];
$_FILES['userfile']['tmp_name'] = $value['tmp_name'][$s];
$_FILES['userfile']['error'] = $value['error'][$s];
$_FILES['userfile']['size'] = $value['size'][$s];
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png|jpeg';
//$config['encrypt_name'] = uniqid(date(1));
// $config['max_size'] = '100';
// $config['max_width'] = '1024';
// $config['max_height'] = '768';
$this->load->library('upload', $config);
$this->upload->do_upload();
$data = $this->upload->data();
$name_array[] = $data['file_name'];
//thumbnail creation
$config['image_library'] = 'gd2';
$config['source_image'] = $data['file_name'];
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['width'] = 200;
$config['height'] = 200;
$this->image_lib->initialize($config);
$this->image_lib->resize();
} // end foreach
$names= array($name_array);
print_r($names);
exit();
}
公共功能附加图像($room\u id)
{
$this->load->lib(“图像库”);
$name_array=array();
$count=计数($_文件['userfile']['size']);
foreach($\文件为$key=>$value)
对于($s=0;$sload->library('upload',$config));
$this->upload->do_upload();
$data=$this->upload->data();
$name_数组[]=$data['file_name'];
//缩略图创建
$config['image_library']='gd2';
$config['source_image']=$data['file_name'];
$config['create_thumb']=TRUE;
$config['maintain_ratio']=TRUE;
$config['width']=200;
$config['height']=200;
$this->image\u lib->initialize($config);
$this->image_lib->resize();
}//结束foreach
$names=数组($name\u数组);
打印(姓名);
退出();
}
这个怎么样
public function addimage($room_id)
{
$this->load->library("image_lib");
$name_array = array();
$count = count($_FILES['userfile']['size']);
foreach($_FILES as $key=>$value)
for($s=0; $s<$count; $s++) {
$_FILES['userfile']['name']=$value['name'][$s];
$_FILES['userfile']['type'] = $value['type'][$s];
$_FILES['userfile']['tmp_name'] = $value['tmp_name'][$s];
$_FILES['userfile']['error'] = $value['error'][$s];
$_FILES['userfile']['size'] = $value['size'][$s];
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png|jpeg';
//$config['encrypt_name'] = uniqid(date(1));
// $config['max_size'] = '100';
// $config['max_width'] = '1024';
// $config['max_height'] = '768';
$this->load->library('upload', $config);
$this->upload->do_upload();
$data = $this->upload->data();
$name_array[] = $data['file_name'];
//thumbnail creation
$config['image_library'] = 'gd2';
$config['source_image'] = $data['file_name'];
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['width'] = 200;
$config['height'] = 200;
$this->image_lib->initialize($config);
$this->image_lib->resize();
} // end foreach
$names= array($name_array);
print_r($names);
exit();
}
公共功能附加图像($room\u id)
{
$this->load->lib(“图像库”);
$name_array=array();
$count=计数($_文件['userfile']['size']);
foreach($\文件为$key=>$value)
对于($s=0;$sload->library('upload',$config));
$this->upload->do_upload();
$data=$this->upload->data();
$name_数组[]=$data['file_name'];
//缩略图创建
$config['image_library']='gd2';
$config['source_image']=$data['file_name'];
$config['create_thumb']=TRUE;
$config['maintain_ratio']=TRUE;
$config['width']=200;
$config['height']=200;
$this->image\u lib->initialize($config);
$this->image_lib->resize();
}//结束foreach
$names=数组($name\u数组);
打印(姓名);
退出();
}
您应该使用以下命令重新初始化图像库:
$this->load->library('image_lib');
$image_config = array(
'source_image' => $image_data['full_path'],
'new_image' => $this->thumbs_path,
'maintain_ratio' => true,
'width' => 36,
'height' => 36
);
$this->image_lib->clear();
$this->image_lib->initialize($image_config);
$this->image_lib->resize();
应使用以下命令重新初始化图像库:
$this->load->library('image_lib');
$image_config = array(
'source_image' => $image_data['full_path'],
'new_image' => $this->thumbs_path,
'maintain_ratio' => true,
'width' => 36,
'height' => 36
);
$this->image_lib->clear();
$this->image_lib->initialize($image_config);
$this->image_lib->resize();
由于我理解你的问题,我建议你阅读有关codeigniter的图像处理库
有一个缩略图创建。成功上载后,您可以使用返回的数据创建缩略图。我理解您的问题,请您阅读codeigniter的图像处理库
有一个缩略图创建。您可以在成功上载后使用返回的数据创建缩略图。Codeigniter用户指南现在位于此处,img_lib抱歉,更新了URL!Codeigniter用户指南现在位于此处,img_lib抱歉,更新了URL!Codeigniter用户指南现在位于此处,img_lib抱歉,更新了URL!