PHP Classes

PHP File Uploading: Simple library to build your file sharing website

Recommend this page to a friend!
  Info   View files Example   View files View files (31)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2024-01-08 (4 days ago) RSS 2.0 feedNot yet rated by the usersTotal: 109 This week: 14All time: 9,611 This week: 16Up
Version License PHP version Categories
phpfileuploading 1.0.1Custom (specified...7Files and Folders, PHP 7, PSR
Description 

Author

PHP Library to help you build your own file sharing website.

Picture of Faris AL-Otabi
  Performance   Level  
Innovation award
Innovation award
Nominee: 3x

 

Recommendations

Example

<?php

include '../src/Upload.php';
include
'../src/File.php';
include
'../src/Utility.php';

use
Farisc0de\PhpFileUploading\File;
use
Farisc0de\PhpFileUploading\Upload;
use
Farisc0de\PhpFileUploading\Utility;

$upload = new Upload(new Utility());

$upload->setUploadFolder([
   
'folder_name' => 'uploads',
   
'folder_path' => realpath('uploads')
]);

$upload->enableProtection();

if (
$_SERVER['REQUEST_METHOD'] == 'POST') {
   
$file = new File($_FILES['file'], new Utility());

   
$upload->setUpload($file);

    if (
$upload->checkIfNotEmpty()) {
        if (!
$upload->checkForbidden()) {
            echo
"Forbidden name";
            exit;
        }

        if (!
$upload->checkExtension()) {
            echo
"Forbidden Extension";
            exit;
        }

        if (!
$upload->checkMime()) {
            echo
"Forbidden Mime";
            exit;
        }

        if (!
$upload->isImage()) {
            echo
"Not Image";
            exit;
        }

       
$upload->upload();

       
$data = json_decode($upload->getJSON(), true);
    }
}
?>

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>File Uploading Service</title>
</head>

<body>
    <?php if (isset($data)) : ?>
<p>You file has been uploaded</p>
    <?php endif; ?>

    <form action="" method="post" enctype="multipart/form-data">
        <input type="file" name="file" id="file">
        <button type="submit">Upload</button>
    </form>

    <div>
        <ul>
            <?php if (isset($data)) : ?>
<li>Filename: <?= $data['filename']; ?></li>
                <li>Filehash: <?= $data['filehash']; ?></li>
                <li>Filesize: <?= $data['filesize']; ?></li>
                <li>Upload at: <?= $data['uploaddate']; ?></li>
            <?php endif; ?>
</ul>
    </div>
</body>

</html>


Details

PhpFileUploading

PHP Library to help you build your own file sharing website.

Features

  1. Simple to use and implement
  2. 4 Protection levels 1. Mime Type 2. Extensions 3. Size 4. Forbidden names
  3. Out Of The Box Functions
  4. Multi-File Upload Support

How to install

composer require farisc0de/phpfileuploading

How to Use

take a look at the documentation and the examples

TODO

Image Manipulation

License

MIT

Copyright

Developed by FarisCode


  Files folder image Files  
File Role Description
Files folder imagedocs (1 file, 9 directories)
Files folder imageexample (3 files)
Files folder imagesrc (5 files)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file composer.lock Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

 Version Control Unique User Downloads Download Rankings  
 100%
Total:109
This week:14
All time:9,611
This week:16Up