async postFileUpload(payload) {
const rnfetchfile = RNFetchBlob.wrap(payload.uri);
try {
console.log(
'POST',
'https://******.***.**/******/***/upload_*******_file',
{
...this.config,
'Content-Type': 'multipart/form-data',
},
[
// element with property `filename` will be transformed into `file` in form data
{
name: 'files',
filename: payload.name,
data: rnfetchfile.replace('file://file:///', 'file://'),
},
],
);
const res = await RNFetchBlob.fetch(
'POST',
'https://******.***.**/******/***/upload_*******_file',
{
...this.config,
'Content-Type': 'multipart/form-data',
},
[
// element with property `filename` will be transformed into `file` in form data
{
name: 'files',
filename: payload.name,
data: rnfetchfile.replace('file://file:///', 'file://'),
},
],
);
const …Run Code Online (Sandbox Code Playgroud) reactjs react-native react-redux react-native-ios rn-fetch-blob
public function store(Request $request)
{
$booking = ($request->isMethod('put')) ? Booking::findOrFail($request->booking_id) : new Booking;
$booking->checkIn = $request->checkIn;
$booking->checkOut = $request->checkOut;
$booking->room_id = $request->room_id;
$booking->user_id = auth()->user()->id;//not working
if($booking->save()){
return new BookingResource($booking);
}
}
Route::put('/booking','BookingsController@store');//api.php
Run Code Online (Sandbox Code Playgroud)
这里 auth()->user()->id 不起作用,但它的工作发现我是否使用相同的代码,但在 paths/web.php 中使用路由代码
laravel ×1
laravel-4 ×1
laravel-5 ×1
laravel-5.1 ×1
php ×1
react-native ×1
react-redux ×1
reactjs ×1