当前位置:首页 » 图片知识 » 如何把轮播图片改成ajax
扩展阅读
女生和渣男搞笑图片 2023-08-31 22:07:09
嘻嘻长什么样图片 2023-08-31 22:06:10

如何把轮播图片改成ajax

发布时间: 2023-08-16 22:03:34

Ⅰ 怎么利用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' => '新增成功!'
]
);
}
}