當前位置:首頁 » 圖片知識 » 如何把輪播圖片改成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' => '新增成功!'
]
);
}
}