在上传过程中重命名文件名

德文德拉·乔汉(Devendra Chauhan)
$uniqId = $this->input->post('U_I_T_Roll_No');
$config['upload_path'] = "./uploads/ProfileImages/";
        $config['allowed_types'] = 'gif|jpg|png|bmp|jpeg';
        $config['max_size']  = '1024';
        $config['max_width']  = '1000';
        $config['max_height']  = '1000';
        /* Load the upload library */
        $this->load->library('upload', $config);
        /* Create the config for image library */
        /* (pretty self-explanatory) */
        $configThumb = array();
        $configThumb['image_library'] = 'gd2';
        $configThumb['source_image'] = '';
        $configThumb['create_thumb'] = FALSE;
        $configThumb['maintain_ratio'] = TRUE;
        /* Set the height and width or thumbs */
        /* Do not worry - CI is pretty smart in resizing */
        /* It will create the largest thumb that can fit in those dimensions */
        /* Thumbs will be saved in same upload dir but with a _thumb suffix */
        /* e.g. 'image.jpg' thumb would be called 'image_thumb.jpg' */
        $configThumb['width'] = 400;
        $configThumb['height'] = 400;
        /* Load the image library */
        $this->load->library('image_lib');

  /* We have 5 files to upload
   * If you want more - change the 6 below as needed
   */
  for($i = 1; $i < 5; $i++) {
    /* Handle the file upload */
    $upload = $this->upload->do_upload('image'.$i);
    /* File failed to upload - continue */
    if($upload === FALSE) continue;
    /* Get the data about the file */
    $data = $this->upload->data();

    $uploadedFiles[$i] = $data;
    /* If the file is an image - create a thumbnail */
    if($data['is_image'] == 1) {
        $configThumb['source_image'] = $data['full_path'];
        $this->image_lib->initialize($configThumb);
        $this->image_lib->resize();
    }
  }
  $S_image = $_FILES['image1']['name'];
  $F_image = $_FILES['image2']['name'];
  $M_image = $_FILES['image3']['name'];
  $LG_image = $_FILES['image4']['name'];
  $data5=array (
    'Uniq_Id' => $this->input->post('U_I_T_Roll_No'),

    'S_image' => $S_image,
    'F_image' => $F_image,
    'M_image' => $M_image,
    'LG_unique1' => $LG_image,
    );


  $this->InsertData->studentimageupload($data5);

上面的代码工作正常。我有4张要上传的图像,并且图像正确保存到数据库中。问题是。

我想根据我的上传图像名称,并将图像名称保存到数据库中。

像: S $ uniqId,F $ uniqId,M $ uniqId,LG $ uniqId

维尼

以前做这样的事情 $this->load->library('upload', $config);

更改$this->load->library('upload', $config);$this->load->library('upload');,看看下面

 for($i = 1; $i < 5; $i++) {
    $img=$_FILES['image'.$i]['name'];
    $new_name=NEW_NAME;
    $ext = strtolower(substr($img, strpos($img,'.'), strlen($img)-1));
    $file_name=$new_name.$ext;
    $config['file_name'] = $file_name;
$this->upload->initialize($config);
/* Handle the file upload */
$upload = $this->upload->do_upload('image'.$i);
/* File failed to upload - continue */
if($upload === FALSE) continue;
/* Get the data about the file */
$data = $this->upload->data();

$uploadedFiles[$i] = $data;
/* If the file is an image - create a thumbnail */
if($data['is_image'] == 1) {
    $configThumb['source_image'] = $data['full_path'];
    $this->image_lib->initialize($configThumb);
    $this->image_lib->resize();
    }
  }

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

在上传过程中重命名图像(PHP)

来自分类Dev

如何在上传过程中重命名图像文件

来自分类Dev

DropBox 在上传过程中不会自动重命名文件

来自分类Dev

在上传过程中重命名图片重要吗

来自分类Dev

在图像上传过程中删除上传按钮和文件名

来自分类Dev

在上传过程中设置自动对焦点

来自分类Dev

在上传过程中向GridFS Meteor FS文件添加自定义属性

来自分类Dev

在上传过程中向GridFS Meteor FS文件添加自定义属性

来自分类Dev

使用netty进行大文件上传时,如何在上传过程中获得上传大小?

来自分类Dev

从CD批量复制文件,并在此过程中重命名不允许的文件名

来自分类Dev

为什么 Alamofire 的上传进度在上传过程中从未达到 1.0 的完成度?

来自分类Dev

在 PowerShell 中重命名文件名

来自分类Dev

使用ggvis的R Shiny应用在上传过程中出现错误

来自分类Dev

如何在文件上传脚本中重命名图像文件名?

来自分类Dev

在安装.appxbundle的过程中如何重命名外部文件

来自分类Dev

Java文件上传在上传时重命名文件

来自分类Dev

Java文件上传在上传时重命名文件

来自分类Dev

重命名文件夹中的文件名-Python

来自分类Dev

根据文件名在python中重命名文件

来自分类Dev

重命名文件夹中的文件名

来自分类Dev

使用Shell重命名文件名中的编号

来自分类Dev

我无法在VS中重命名文件名

来自分类Dev

在CentOS 7中批量重命名JPG文件名

来自分类Dev

重命名多个目录中的文件名

来自分类Dev

使用PowerShell重命名或删除文件名中的字符

来自分类Dev

PowerShell - 重命名对象数组中的重复文件名

来自分类Dev

如何在FTP上传过程中禁止显示“正在复制”窗口?

来自分类Dev

PHP-文件上传过程重置

来自分类Dev

PHP-文件上传过程重置

Related 相关文章

  1. 1

    在上传过程中重命名图像(PHP)

  2. 2

    如何在上传过程中重命名图像文件

  3. 3

    DropBox 在上传过程中不会自动重命名文件

  4. 4

    在上传过程中重命名图片重要吗

  5. 5

    在图像上传过程中删除上传按钮和文件名

  6. 6

    在上传过程中设置自动对焦点

  7. 7

    在上传过程中向GridFS Meteor FS文件添加自定义属性

  8. 8

    在上传过程中向GridFS Meteor FS文件添加自定义属性

  9. 9

    使用netty进行大文件上传时,如何在上传过程中获得上传大小?

  10. 10

    从CD批量复制文件,并在此过程中重命名不允许的文件名

  11. 11

    为什么 Alamofire 的上传进度在上传过程中从未达到 1.0 的完成度?

  12. 12

    在 PowerShell 中重命名文件名

  13. 13

    使用ggvis的R Shiny应用在上传过程中出现错误

  14. 14

    如何在文件上传脚本中重命名图像文件名?

  15. 15

    在安装.appxbundle的过程中如何重命名外部文件

  16. 16

    Java文件上传在上传时重命名文件

  17. 17

    Java文件上传在上传时重命名文件

  18. 18

    重命名文件夹中的文件名-Python

  19. 19

    根据文件名在python中重命名文件

  20. 20

    重命名文件夹中的文件名

  21. 21

    使用Shell重命名文件名中的编号

  22. 22

    我无法在VS中重命名文件名

  23. 23

    在CentOS 7中批量重命名JPG文件名

  24. 24

    重命名多个目录中的文件名

  25. 25

    使用PowerShell重命名或删除文件名中的字符

  26. 26

    PowerShell - 重命名对象数组中的重复文件名

  27. 27

    如何在FTP上传过程中禁止显示“正在复制”窗口?

  28. 28

    PHP-文件上传过程重置

  29. 29

    PHP-文件上传过程重置

热门标签

归档