12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
- namespace App\Admin\Controllers;
- use App\Http\Controllers\Controller;
- use Illuminate\Support\Facades\Storage;
- use Illuminate\Http\Request;
- use App\Repositories\Eloquent\BaseRepository;
- /**
- *
- * @author lilin
- *
- */
- class UploadController extends Controller
- {
- public function store(Request $request){
- $save=array();
- $all_file=$request->allFiles();
- foreach ($all_file['wangEditorH5File'] as $key => $value) {
- if ($value->isValid()) {
- $result = '/storage/'.Storage::disk("public")->putFile("editor", $value);
- $save[]=config('app.url').$result;
- }
- }
- echo json_encode(array('errno'=>0,'data'=>$save));
- }
-
- public function imUploadPic(Request $request)
- {
- $dst = 'im';
-
- $file = $request->file('file');
-
- $picInfo = getimagesize($file);
- if (! $picInfo) {
- return self::returnCode('sys.notImageFile');
- }
-
- $srcPath = $file->getPathname();
- $extension = $file->getClientOriginalExtension();
- // $fileName = time() . rand(). '.' . $extension;
- $dstPath = $dst . '/' . date('Ym') ;
-
- $path = $request->file('file')->store($dstPath);
-
- return ['code'=>1000, 'data'=>['pic'=>$path]];
- }
- }
|