我正在尝试发送带有图像的表单。注意:我不想将图像保存在数据库中,我想将它保存在我在服务器上创建的文件夹中,然后将图像的链接添加到数据库中。
从服务器端我知道如何处理这个,但我不知道如何从字体端做到这一点。换句话说,如何使用 axios 将图像发送到服务器。
<template>
<input type="text" class="form-control" id="specdesc" v-model="product.specdesc" name="specdesc" placeholder="Enter your name">
<input type="file" name="image" id="image" accept="image/*" >
<button type="submit" class="btn btn-sm btn-primary"@click.prevent="Submit()"> Submit</button>
</template>
<script>
export default {
name: 'Addproduct',
data(){
return{
image: '',
product:{
specdesc:'',
},
}
},
methods:{
Submit(){
var _this=this
// console.log(this.image)
console.log(this.selectedCategory.category_name)
var product = {
specification:this.product.specdesc,
imagename:this.image
}
this.$http.post('http://localhost:3000/api/companyproducts',product)
.then(function (response) {
console.log(response.data);
})
.catch(function (error) {
console.log("error.response");
});
}
},
}
</script>
Run Code Online (Sandbox Code Playgroud)
现在我的问题是如何使用 axios 上传图像以及输入名称。此外,我想使用相同的方法即var product发送。
我刚接触vue&我做了很多谷歌,但没有找到任何与我目前的情况相匹配的解决方案所以不知道我怎么能在vue组件中传递路线,有没有办法将这个laravel路由传递到vue模板中下面.我的vue是位置资源/ assets/js这里是代码
<template>
<a href={{route('/')}}></a>//i want to pass laravel route
//to view component this line
//throw error
</template>
Run Code Online (Sandbox Code Playgroud)
route(web.php)代码
Route::get('/' , function(){
Return view('homepage');
});
Run Code Online (Sandbox Code Playgroud)
我想将此url传递给位置(vue)为的vue组件 resource/assets/js
我是javaFx的新手,所以请忽略我在这里的愚蠢问题我要验证(限制)用户输入3个字符(如果用户输入更多输入,则不允许或3个字符后,后者应该可见)我发现很多验证的解决方案,但它不限制最多3个字符,也不会有点混淆理解这是我的代码.
public class editController {
@FXML
private TextField countrycode;
public void add(ActionEvent event) {
String ADD=countrycode.getText();
try {
if(ADD.isEmpty()){
Alert alert=new Alert(Alert.AlertType.ERROR);
alert.setHeaderText(null);
alert.setContentText("Please Fill All DATA");
alert.showAndWait();
return;
}
FXMLLoader loader =new FXMLLoader();
loader.load(getClass().getResource("/region/newCountry.fxml").openStream());
Run Code Online (Sandbox Code Playgroud)