Good, I have a problem regarding the way you sent file values, how I use ajax in jquery and the jquery-formdata library, I get the error of TypeError: 'slice' called on an object that does not implement interface Blob.
I think it's because all those values in the fields I store them as a JSON object, plus I use laravel to save the images, or at least that's supposed:
function FormInfo()
{
var valor = $("#addUserForm").serialize();
var json = {};
var datos = valor.split("&");
datos.forEach(function(element, index) {
var info = element.split("=");
json[""+info[0]] = info[1];
});
json["avatar"] = document.getElementById('plox').files[0];
return json;
}
This is the code with which I get the values of the input and I pass them to a json as I add the value of the file.
$("#addUserForm").submit(function (event) {
//Ocultando todos los mensajes de error
$('.chip').hide();
event.preventDefault();
$.ajaxFormData({
type: "post",
dataType: "html",
url: 'users/add',
contentType: "multipart/form-data",
data : FormInfo(),
success: function (response) {
$("#addUser").modal('close');
$("#cont-users").addClass('formSubmitted');
Materialize.toast('Registro ingresado', 3000, 'rounded');
}
And this one here is the code by which I send the data, and this is the line of code of the user driver in laravel that gives me error:
$request->file('avatar')->store('public');
This is the form tag
<form method="POST" action="http://127.0.0.1:8000/users/add" accept-charset="UTF-8" id="addUserForm"><input name="_token" value="kl5DY0aNK0mUt3lR9pGnoeEX8GOlPhdLJkSSh0hd" type="hidden">