Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用laravel后端API在nuxt.js中制作图像上传表单_Laravel_Vue.js_Nuxt.js_Nuxtjs_Linux Toolchain - Fatal编程技术网

如何使用laravel后端API在nuxt.js中制作图像上传表单

如何使用laravel后端API在nuxt.js中制作图像上传表单,laravel,vue.js,nuxt.js,nuxtjs,linux-toolchain,Laravel,Vue.js,Nuxt.js,Nuxtjs,Linux Toolchain,我在nuxt.js中学到了很多东西,但我对上传图像印象深刻。如果有人分享你的知识 如何在nuxt.js中制作图像上传表单 我创建了用于图像上传的laravel API。 我的路由器 Route::group(['middleware' => 'auth:api'], function() { Route::post('/Employeeregister', 'EMPLOYEE_API\RegisterController@register')->name('Employeeregis

我在nuxt.js中学到了很多东西,但我对上传图像印象深刻。如果有人分享你的知识

如何在nuxt.js中制作图像上传表单

我创建了用于图像上传的laravel API。

我的路由器

Route::group(['middleware' => 'auth:api'], function() {
Route::post('/Employeeregister', 'EMPLOYEE_API\RegisterController@register')->name('Employeeregister');

}); 
控制器代码

 public function imageUploadPost(Request $request)
    {
        $request->validate([
            'name' =>  'required | string',
            'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
        ]);
  
        $imageName = time().'.'.$request->image->extension();  
   
        $request->image->move(public_path('images'), $imageName);
   
        return back()
            ->with('success','You have successfully upload image.')
            ->with('image',$imageName);
   
    }
我的Nuxt代码

<template>
    <v-row justify="center">
        <v-col cols="12" sm="6">
            <form @submit.prevent="submit">
                <v-card ref="form" >
                    <v-card-text>
                        <h3 class="text-center">Register</h3>
                        <v-divider class="mt-3"></v-divider>
                        <v-col cols="12" sm="12">
                            <v-text-field v-model.trim="form.name" type="text" label="Full Name" solo autocomplete="off"></v-text-field>
                        </v-col>
<v-col cols="12" sm="12"><v-file-field v-model.trim="form.image" type="file" label="image" solo autocomplete="off"></v-file-field>
                            </v-col>
                    </v-card-text>
                    <v-card-actions>
                        <v-spacer></v-spacer>
                        <div class="text-center">
                            <v-btn rounded type="submit" color="primary" dark>Register</v-btn>
                        </div>
                    </v-card-actions>
                </v-card>
            </form>
        </v-col>
    </v-row>
</template>
< script >
  export default {
    middleware: ['guest'],
    data() {
      return {
        form: {
          name: '',image: '',
        }
      }
    },
  } <
  /script>

登记
登记