Ⅰ 怎么利用ajax调用后台返回的图片轮播的接口
<?php
namespace App\Http\Controllers\Admin;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
class BannerController extends Controller
{
public function BannerCreate(Request $request)
{
$file = $request->file('photo');//获取图片
$theme = $request->theme;//主题
$status = $request->status;//状态
$allowed_extensions = ["png", "jpg", "gif"];
if ($file->getClientOriginalExtension() && !in_array($file->getClientOriginalExtension(), $allowed_extensions)) {
return response()->json([
'status' => false,
'message' => '只能上传 png | jpg | gif格式的图片'
]);
}
if ($request->hasFile('photo')) {
}
$destinationPath = 'storage/uploads/';
$extension = $file->getClientOriginalExtension();
$fileName = str_random(10).'.'.$extension;
$file->move($destinationPath, $fileName);
return Response()->json(
[
'status' => true,
'pic' => asset($destinationPath.$fileName),
'isMake' => $status,
'message' => '新增成功!'
]
);
}
}