FIle Uploader is a php package to aid fast , easy and safe file upload

Overview

FILE UPLOADER

FIle Uploader is a php package to aid fast , easy and safe file upload

installation

composer require codad5/file-helper

Features

  • Fast and easy to use with method chaining
  • Good error management
  • Safety management
  • works for both multiple file upload and single file upload

Usage

index.php

">
<form action="./upload.php" method='post' enctype="multipart/form-data">
    <input type="file" name="test[]" multiple>
    <input value="submit" type="submit">
form>

upload.php


    include(__DIR__ . '/../vendor/autoload.php');
    
    $file_upload_controller = new Codad5\FileHelper\FileUploader('test', "uploads/");

test - the name given to the $_FILES array by default - for refrence $_FILES['test]`

uploads/ - Upload path relative to upload.php

To add allowed extension

#any other extension aid the given will give error or ignored depending on your error settings
$file_upload_controller->add_ext('svg', 'png');

To set File Prefix

# for unique id can be replaced with uniqid('', true)
$file_upload_controller->set_prefix('my prefix');

To set max and min size

$file_upload_controller->set_sizes(10000, 20);

10000 - This is the maximum file size allowed, to ignore for your .ini config set it to null 20 - This is the minimum file size allowed default equals 0

Turing on/Off Error reporting

/**
 * This is use to turn on and off reporting of the upload process
 * @param bool $file_error - to report error imbound in file from request if `true` else ignore
 * @param bool $size_error - TO report size related error if `true` else ignore
 * @param bool $type_error - To report error related to file type if `true` else ignore
 */
$file_upload_controller->set_reporting(true, false, true);
  • The first param $file_error is to report error imbounded in file from request as found in $_SERVER['test']
  • The second param $size_error is to report size related error depending on your settings
  • The Third param $type_error is to report error if a file is not part of the allowed file

NOTE: If any is false and error is found it will ignore the file and continue upload with out the file

Moving the file

$file_upload_controller->move_files();

Get Uploaded file path

; } ">
$upload_path = $file_upload_controller->get_uploads();

foreach ($upload_path as $key => $value) {
        # code...
        echo "This file has been uploaded to ".$value['uploaded_path']."
; }
  • This returns a multi-dimensional array of each array with the following key
  • uploaded_path - The final uploaded file with path relative to the script tag upload.php
  • name - The name of the file
  • size - The size of the file
  • type - The file Type
  • ext - The file extension

Method Chaining

set_reporting(false, false, false) ->add_ext('png', 'pdf') ->set_prefix('cool Stuff') ->move_files() ->get_uploads(); foreach ($uploaded_file_array as $key => $value) { # code... echo "This file has been uploaded to ".$value['uploaded_path']."
"; } ">
$file_upload_controller = new \Codad5\FileHelper\FileUploader('tes', "uploads/");

    $uploaded_file_array = $file_upload_controller
    ->set_reporting(false, false, false)
    ->add_ext('png', 'pdf')
    ->set_prefix('cool Stuff')
    ->move_files()
    ->get_uploads();

    foreach ($uploaded_file_array as $key => $value) {
        # code...
        echo "This file has been uploaded to ".$value['uploaded_path']."
"; }

This documentaion will be updated in time as the project grows for enquire and more information contact me here

Built with 💗 by Chibueze Michael A.

You might also like...
CSV data manipulation made easy in PHP

CSV Csv is a simple library to ease CSV parsing, writing and filtering in PHP. The goal of the library is to be powerful while remaining lightweight,

Private file storage and share with user build with laravel and vue inspired by google drive
Private file storage and share with user build with laravel and vue inspired by google drive

LaravelDrive is a file storage system that allows store private file and share with users build wiht laravel and vue inspired by google drive. Laravel

Detects file type by filename or content and generates correct mimetype.

FileTypeDetector Files type detector based on file name extension or file content (binary content). Usage Installation Supported formats Usage File Ty

Uguu is a simple lightweight temporary file host with support for drop, paste, click and API uploading.

Uguu What is Uguu? Uguu is a simple lightweight temporary file hosting and sharing platform, but can also be used as a permanent file host. Features O

Media gallery with CKEditor, TinyMCE and Summernote support. Built on Laravel file system.
Media gallery with CKEditor, TinyMCE and Summernote support. Built on Laravel file system.

Documents ・ Installation ・ Integration ・ Config ・ Customization ・ Events ・ Upgrade ・ Demo ・ FAQ Features File upload and management Uploading validati

A lightweight file manager with full ShareX, Screencloud support and more
A lightweight file manager with full ShareX, Screencloud support and more

XBackBone is a simple, self-hosted, lightweight PHP file manager that support the instant sharing tool ShareX and *NIX systems. It supports uploading

Pomf is a simple lightweight file host with support for drop, paste, click and API uploading.

Pomf Pomf is a simple file uploading and sharing platform. Features One click uploading, no registration required A minimal, modern web interface Drag

Watch changes in the file system using PHP
Watch changes in the file system using PHP

Watch changes in the file system using PHP This package allows you to react to all kinds of changes in the file system. Here's how you can run code wh

File manager module for the Lumen PHP framework.

Lumen File Manager File manager module for the Lumen PHP framework. Please note that this module is still under active development. NOTE: Branch 5.1 i

Releases(v1.0.2)
Owner
Aniezeofor Chibueze Michael
A full-stack web developer with the dream of improving society with my skill and knowledge
Aniezeofor Chibueze Michael
Creating a file uploader with Laravel

File-Uploader File uploader is a simple group of restful APIs built in Laravel to upload file into a server and remove the file from that server. Tool

AmirH.Najafizadeh 4 Jul 31, 2022
Upload File Library For PHP ( Simple & Easy User )

Upload File Library For Backend/ServerSide PHP ( Simple & Easy For Use ), Support Multiple Upload

Lamhot Simamora 1 Oct 12, 2021
A php sharex uploader with discord embed function/twitter card support

Sharex Uploader Simple Sharex Uploader with Discord embed function Download replace your data and upload to your sevrer

Clynt 4 Jan 9, 2022
ORM-based file upload package for php.

#Stapler Note: If you've previously been using this package, then you've been using it with Laravel. This package is no longer directly coupled to the

Code Sleeve 541 Dec 30, 2022
Basic anonymous and registered upload storage for temporary share file self hosted.

TMPShareX Basic anonymous and registered upload storage for temporary share file self hosted. Server Requirement PHP 7.4.8 [Support PHP 8] Nginx 1.19.

Sandy Hermansyah 1 Feb 3, 2022
This package used to upload files using laravel-media-library before saving model.

Laravel Media Uploader This package used to upload files using laravel-media-library before saving model. In this package all uploaded media will be p

Ahmed Fathy 312 Dec 12, 2022
This project is a demo for Media-Upload package:

??️ Media-Upload-Demo This project is a demo for Media-Upload package: ?? Installation guide As always you need to: composer install Then npm install

Mohamed Hafidi 9 Jan 9, 2023
☁️ Nextcloud server, a safe home for all your data

Nextcloud Server ☁ A safe home for all your data. Why is this so awesome? ?? ?? Access your Data You can store your files, contacts, calendars and mor

Nextcloud 21.1k Dec 31, 2022
Tailwind plugin to generate purge-safe.txt files

Tailwind plugin to generate safelist.txt files With tailwind-safelist-generator, you can generate a safelist.txt file for your theme based on a set of

Spatie 89 Dec 23, 2022
PictShare is an open source image, mp4, pastebin hosting service with a simple resizing and upload API that you can host yourself.

PictShare is an open source image, mp4, pastebin hosting service with a simple resizing and upload API that you can host yourself.

Haschek Solutions 709 Jan 3, 2023