I'm uploading a file using the bootstrap input file plugin which I succeed in uploading in what I submit makes it difficult to return the path to the plugin to order or delete them in the documentation I have 2 methods that are
initialPreview: [
'<img src='/images/desert.jpg' class='file-preview-image' alt='Desert' title='Desert'>',
],
and the other one is
initialPreviewConfig: [
{
caption: 'desert.jpg',
width: '120px',
url: 'http://localhost/avatar/delete', // server delete action
key: 100,
extra: {id: 100}
}
]
but it indicates that I must return them in json which I do but nothing happens, it does not update the field file this is my controller
public function Save(Request $request)
{
if($request->ajax())
{
//obtenemos el campo file definido en el formulario
$file = $request->file('input-25');
//obtenemos el nombre del archivo
$nombre = $file->getClientOriginalName();
//indicamos que queremos guardar un nuevo archivo en el disco local
\Storage::disk('local')->put($nombre, \File::get($file));
$public_path = public_path();
$url = $public_path.'/storage/'.$nombre;
$initialPreview= array(
'$url'
);
return response()->json($initialPreview);
}
}
and this is the plugin script
$("#input-25").fileinput({
uploadUrl: "{{ url('/subirpdf')}}",
uploadExtraData: {_token:"{{csrf_token()}}"},
language: "es",
maxFileSize: 1000,
required: true,
allowedFileExtensions: ["pdf"],
showRemove: true,
initialCaption: "Subir Archivo en pdf con las caracteristicas del producto",
msgFilerequired: true,
showUploadedThumbs:false,
initialPreviewAsData: true,
deleteUrl:"{{ url('/eliminarpdf')}}",
});