【发布时间】:2020-02-21 20:31:02
【问题描述】:
我完全是 Laravel 的初学者,所以请先生帮助我。
我将发送Image_Mode="Gallery" 来自
反应 axios.post() 并想在 laravel 控制器中获取 Image_Mode 值。
示例:
$img_mode = $request->input('img_mode');
反应代码
fileUploadHandler = (e) =>{ 让 img_mode =''; const config = { headers: { 'Content-Type': 'multipart/form-data' } , img_mode:this.state.img_mode};
let formData = new FormData();
formData.append("file", this.state.selectedFile);
axios.post(`http://127.0.0.1:8000/api/ImageUpload`, formData,config,img_mode)
.then(res => {
console.log(res);
console.log(res.data);
})
}
【问题讨论】:
-
dd($request->all()); ?
-
你能展示一下你用来发送ajax的js代码吗?
-
先生,我将附上输出屏幕截图。 img_mode:"Gallery" 获取并且我想在我的控制器中使用 img_mode 值
-
fileUploadHandler = (e) =>{ let img_mode =''; const config = { headers: { 'Content-Type': 'multipart/form-data' } , img_mode:this.state.img_mode};让 formData = new FormData(); formData.append("文件", this.state.selectedFile); axios.post(
http://127.0.0.1:8000/api/ImageUpload, formData,config,img_mode) .then(res => { console.log(res); console.log(res.data); }) }
标签: php reactjs laravel request