Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/litto/uploader

File Uploader Class for Files in PHP
https://github.com/litto/uploader

Last synced: about 1 month ago
JSON representation

File Uploader Class for Files in PHP

Awesome Lists containing this project

README

        

# File Uploader

File Uploader Class for Files in PHP

##How to Install?

Install Using Composer or Direcly you can download from the Github Code You can install via composer by using this command:-

composer require litto/uploader:v1.0

## How it works?

When File is submitted in a form. In the save function call like this:-

$absDirName = dirname(dirname(__FILE__)).'/uploads'; // uploads folder where you are storing files
$uploader = new Uploader($absDirName.'/'); //Initilize Class passing the uploader path
$uploader->setExtensions(array('jpg','jpeg','png','gif')); // Restrict the Formats valid for thsi file upload
$uploader->setSequence('page'); // You can set name sequence or you can pass the slug varibale for making seo friendly
$uploader->setMaxSize(2); // Set size of the Uploader file in MB
if($uploader->uploadFile("txtFile")){ // Class is uplaoding file where our file field name is txtFile
/*
* File uploader successfully , now store to Db
*/
$image = $uploader->getUploadName(); //getting uploaded file name
// You can store the file in your database
}