It turns out that I have the following code to do an update in laravel with query builder .
public function editarCedente(Request $request)
{
$id_cedente_e = $request->id_cedente_edit;
$nombre_cedente_e = $request->edit_nombre_cede;
$path = $request->file('edita_imagen_cedente');
$imagen_cedente_e = File::get($path);
//llamo a la funcion estatica de un archivo que he creado
//para el Procedimiento alamacenado
$edita_cedente = S_Update_Cedente::get_update_cedente($id_cedente_e,$nombre_cedente_e,base64_encode($imagen_cedente_e));
return redirect()->route('cedentes');
}
This is the static function
public static function get_update_cedente($id_cedente_e,$nombre_cedente_e,$imagen_cedente_e)
{
$update_cedente = DB::select('exec S_Update_Cedente '.$id_cedente_e.', "'.$nombre_cedente_e.'", "'.$imagen_cedente_e.'" ');
return $update_cedente;
}
The error it gives me is the following:
So I don't know what it could be if I'm doing something wrong or I need another way to do this, the data types would be the following in the databasesql server:
- id_grantor type
int
. - grantor_name type
varchar
. - image_cedent type
image
PS: it is a requirement to save it in base 64 in the database, I also thought of saving only the url of the image.
Because of the double quotes, you are taking the data as an identifier (table or column name depending on the context) and since the base64 is very large, this error jumps (identifier very large), if the image were small it would give you the error "invalid column name" for example the base64 of a transparent gif:
R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
it can be used as a table/column name but in this schema it would not be found.you can try using single quotes
or calling the procedure via parameters
Or as they point out in the comments, deactivate
QUOTED_IDENTIFIER
in SQL how and where to deactivate it will depend on the store procedure. For example, I leave you a fiddle:http://www.sqlfiddle.com/#!18/11d01
on the msdn page there is an example of combining the
ON
and theOFF
https://docs.microsoft.com/en-us/sql/t-sql/statements/set-quoted-identifier-transact-sql
I handle uploading photos this way:
Go to this link to install the Image
http://image.intervention.io/getting_started/installation
Then implement it like this
In controller:
And in the view I put an enctype: