1. Go to this page and download the library: Download sczts/laravel-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/ */
sczts / laravel-upload example snippets
use Sczts\Upload\Upload;
class CommonController extends Controller
{
// 上传文件
public function upload(Request $request,Upload $upload)
{
$file = $request->file('file');
$data = $upload->upload($file);
return $this->json(StatusCode::SUCCESS, $data);
}
}
use Sczts\Upload\Facades\Upload;
class CommonController extends Controller
{
// 上传文件
public function upload(Request $request)
{
$file = $request->file('file');
$data = Upload::upload($file);
return $this->json(StatusCode::SUCCESS, $data);
}
}