PHP code example of mhndev / media

1. Go to this page and download the library: Download mhndev/media 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/ */

    

mhndev / media example snippets



define('ROOT', pathinfo(__FILE__)['dirname']);

define('IMAGE_PATH', ROOT.DIRECTORY_SEPARATOR.'storage'.DIRECTORY_SEPARATOR.'image');
define('AUDIO_PATH', ROOT.DIRECTORY_SEPARATOR.'storage'.DIRECTORY_SEPARATOR.'audio');
define('VIDEO_PATH', ROOT.DIRECTORY_SEPARATOR.'storage'.DIRECTORY_SEPARATOR.'video');
define('TEXT_PATH' , ROOT.DIRECTORY_SEPARATOR.'storage'.DIRECTORY_SEPARATOR.'text');



\mhndev\media\UploadFile::config([

    'min_storage' => 100,
    
    'formats'=>[
        'image'=>[
            'avatar'=>[
                'storagePath'=> IMAGE_PATH.DIRECTORY_SEPARATOR.'avatar',
                'uploadSizeLimit' => 2,
            ]
        ],
        'audio'=>[
            'music'=>[
                'storagePath'=> AUDIO_PATH.DIRECTORY_SEPARATOR.'music',
                'uploadSizeLimit' => 10
    
            ],
            'madahi'=>[
                'storagePath'=> AUDIO_PATH.DIRECTORY_SEPARATOR.'madahi',
                'uploadSizeLimit' => 4
    
            ]
        ],
        'video'=>[
            'storagePath'=> VIDEO_PATH,
            'uploadSizeLimit' => 10
        ],
        'text'=>[
            'license'=>[
                'storagePath'=> TEXT_PATH.DIRECTORY_SEPARATOR.'license',
                'uploadSizeLimit' => 1
            ]
        ]
    ]

]);


\mhndev\media\UploadFile::store('text', 'license');
\mhndev\media\UploadFile::store('music', 'music');