PHP code example of rain_sunshine_cloud / uploads

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

    

rain_sunshine_cloud / uploads example snippets


try{
    //文件上传
    Upload::upload('file_input_name')->getFilePath(true);
    //图片上传
    Upload::uploadImg('img_input_name')->getFilePath(true);
    //base6464图片上传(使用post)
    Upload::uploadImg('img_input_name',true)->getFileName(true);
    //base64图片上传(使用get)
    Upload::uploadImg('img_input_name',true,'get')->getFileName(true);
    //base64图片上传(使用json)
    Upload::uploadImg('img_input_name',true.'json')->getFileName(true);

    //设置属性

    //设置基础路径
    Upload::setBasePath('/usr/local/public/');
    //其他临时设置
    $file = new Upload();
    $file->setDir('文件夹')->setPrefixName('前缀')->setValidType(['jpg'])->setMaxSize(100000)->upload('file_input_name')->getFilePath(true);

} catch (UploadException $e) {
    echo $e->getMessage();
}