项目作者: ctechhindi

项目描述 :
CodeIgniter 3.x Library - Multiple File Upload and Validation
高级语言: PHP
项目地址: git://github.com/ctechhindi/CodeIgniter-Multiple-File-Upload-Library.git
创建时间: 2020-01-18T03:43:49Z
项目社区:https://github.com/ctechhindi/CodeIgniter-Multiple-File-Upload-Library

开源协议:MIT License

下载


CodeIgniter-Multiple-File-Upload-Library

CodeIgniter 3.x Library - Multiple File Upload and Validation

Installation

Simply copy the Upload_documents.php file to your applications library directory.

Required

  • PHP Extension gd and gmp

Use

Fields

  1. $this->load->library('upload_documents');
  2. $output = $this->upload_documents->run([
  3. 'field_name' => 'file_name', // Field Name
  4. 'upload_path' => './upload/images/', // Upload Path
  5. 'allowed_types' => 'jpg|png|jpeg', // File Types
  6. // 'encrypt_name' => TRUE, // Change File Name
  7. // 'overwrite' => TRUE,
  8. // 'max_size' => 55,
  9. // 'max_filename' => '255',
  10. // 'max_width' => 18222,
  11. // 'min_width' => 19222,
  12. // 'max_height' => 1722,
  13. // 'min_height' => 1262,
  14. 'thumbs' => [
  15. 'small' => [ 'w' => 28, 'h'=> 28, 'path' => './upload/images/'],
  16. // 'key' => [ 'w' => wight, 'h'=> height, 'path' => 'upload path'],
  17. ],
  18. ]);

Upload Only Single File

  1. // Load Library: Document Upload
  2. $this->load->library('upload_documents');
  3. $output = $this->upload_documents->run([
  4. 'field_name' => 'file_field_name', // Field Name
  5. 'upload_path' => './assets/image/', // Upload Path
  6. 'allowed_types' => 'jpg|png|jpeg', // File Types
  7. 'max_size' => 200, // Maximum File Size (KB)
  8. 'thumbs' => [ // Image Thumbnail Size
  9. "x128" => [ 'w' => 128, 'h'=> 128, 'path' => './assets/image/thumb/'],
  10. "x192" => [ 'w' => 192, 'h'=> 192, 'path' => './assets/image/thumb/'],
  11. "x256" => [ 'w' => 256, 'h'=> 256, 'path' => './assets/image/thumb/'],
  12. "x512" => [ 'w' => 512, 'h'=> 512, 'path' => './assets/image/thumb/'],
  13. ],
  14. ]);
  15. print_r($output); // $output['status'] = TRUE/FALSE

Upload Multiple File One Time

Firstly check file validation then uploading start.

  1. // Load Library: Document Upload
  2. $this->load->library('upload_documents');
  3. // Upload Multiple Files
  4. $output = $this->upload_documents->multi([
  5. 'field_name' => 'file_field_name', // Field Name
  6. 'upload_path' => './assets/image/', // Upload Path
  7. 'allowed_types' => 'jpg|png|jpeg', // File Types
  8. 'max_size' => 300, // Maximum File Size (KB)
  9. 'thumbs' => [
  10. "x256" => [ 'w' => 256, 'h'=> 256, 'path' => './assets/image/thumb/'],
  11. "x512" => [ 'w' => 512, 'h'=> 512, 'path' => './assets/image/thumb/'],
  12. ],
  13. ]);

Fetch Upload Images and Doc

  1. // Load Library: Document Upload
  2. $this->load->library('upload_documents');
  3. $output = $this->upload_documents->show_image(base_url('upload/images/'), 'file_name.png', 'key');
  4. var_dump($output);
  5. // AND
  6. [
  7. // Original File
  8. "org" => $this->upload_documents->show_image(base_url('/assets/building/'), $fileName),
  9. // Image Thumbnail's
  10. "x128" => $this->upload_documents->show_image(base_url('/assets/building/thumb/'), $fileName, 'x128'),
  11. "x192" => $this->upload_documents->show_image(base_url('/assets/building/thumb/'), $fileName, 'x192'),
  12. "x256" => $this->upload_documents->show_image(base_url('/assets/building/thumb/'), $fileName, 'x256'),
  13. "x512" => $this->upload_documents->show_image(base_url('/assets/building/thumb/'), $fileName, 'x512'),
  14. ]

Delete Image & Doc in Server

  1. $img_x128Path = $this->upload_documents->show_image_path(FCPATH. '/assets/building/thumb/', $fileName, "x128");
  2. unlink($img_x128Path);

Reporting Issues ☢️

If you have a problem with this plugin or found any bug, please open an issue on GitHub.

Code copyright 2020 ctechhindi. Code released under the MIT license