PHP code example of wll / hyperf-upload

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

    

wll / hyperf-upload example snippets

bash
bin/hyperf.php vendor:publish hyperf-upload
bash

use Hyperf\Utils\ApplicationContext;
use Wll\HyperfUpload\Service\FileStoreInterface;

 public function index(){	
 
   $container = ApplicationContext::getContainer();
   $upload=$container->get(FileStoreInterface::class); //获得上传对象
   
	//返回文件名+扩展名
	$path = $upload->store($request->file('file'));
	
	print_r($path);
	
	//获取可以访问的url
	echo "http的访问url".$upload->url($path);  
	
	
	//删除 
	$a=$upload->delete(['images/43704c244ee5fc5dcb83402f88f33144.jpg']);
	
	if($a){
		echo 'dd';
	}else{
		echo 'ccc';
	}			
   
   	
}