PHP code example of sunsgne / webman-multipart-upload

1. Go to this page and download the library: Download sunsgne/webman-multipart-upload 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/ */

    

sunsgne / webman-multipart-upload example snippets


    public function MultipartUpload(Request $request): Response
    {
        try {
            $data = v::input($request->post(), [
                'action'      => v::nullable(v::stringVal()->in(['slice', 'merge']))->setName("action"),
                'filename'    => v::stringVal()->setName("filename"),
                'chunk'       => v::nullable(v::intVal()->min(0))->setName("chunk"),
                'chunkLength' => v::intVal()->min(0)->setName("chunkLength"),
                'uuid'        => v::stringVal()->setName("uuid"), 
            ]);
            $apk  = $request->file('files');
            /** 验证上传分片必须的参数 */
            if ($request->post('action') == 'slice' && is_null($request->post('chunk'))) {
                return response_error(ErrorCode::BAD_REQUEST, "chunk :BAD_REQUEST, $e->getMessage());
        }
    }