PHP code example of codeblog / datauploader

1. Go to this page and download the library: Download codeblog/datauploader library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

codeblog / datauploader example snippets



ge = new CodeBlog\DataUploader\Image("uploads", "images");

if ($_FILES) {
    try {
        $upload = $image->upload($_FILES['image'], $_POST['name'], 400);
        echo "<img src='{$upload}' />";
    } catch (Exception $e) {
        echo "<p>(!) {$e->getMessage()}</p>";
    }
}


e = new CodeBlog\DataUploader\File("uploads", "files");

if ($_FILES) {
    try {
        $upload = $file->upload($_FILES['file'], $_POST['name']);
        echo "<p><a href='{$upload}' target='_blank'>Link File</a></p>";
    } catch (Exception $e) {
        echo "<p>(!) {$e->getMessage()}</p>";
    }
}


ia = new CodeBlog\DataUploader\Media("uploads", "medias");

if ($_FILES) {
    try {
        $upload = $media->upload($_FILES['file'], $_POST['name']);
        echo "<p><a href='{$upload}' target='_blank'>Link Media</a></p>";
    } catch (Exception $e) {
        echo "<p>(!) {$e->getMessage()}</p>";
    }
}