I have a list of form such this code and need to save data with js,my code in blade file is here:
<input type='file' id="Pre_File">
<input type="text" id="Product_Name" class="profile-input">
<textarea type="text" id="Product_Desc" class="profile-input"></textarea>
<div id="ProSave">
<div class="card-footer">
<button type="submit">Save</button>
</div>
</div>
And jquery that I used to save Product_Name and Product_Desc is here:
<script>
$(document).ready(function (event) {
$('#ProSave').click(function (event) {
var Product_Name = $('#Product_Name').val();
var Product_Desc = $('#Product_Desc').val();
$.post('/Product/Free/Save', {
'Product_Name': Product_Name,
'Product_Desc': Product_Desc,
'_token': $('input[name=_token]').val()
});
});
</script>
And Controller has this code:
public function Add(Request $request){
$product = new Product;
$product->product_name = $request->Product_Name;
$product->product_desc = $request->Product_Desc;
$product->save();
}
How I Can get file input and move file folder in public and save in database?