return file property on update and create to show image imidiately
This commit is contained in:
parent
b349690996
commit
47dcc79752
1 changed files with 13 additions and 9 deletions
|
@ -56,6 +56,7 @@ class ItemController extends Controller
|
||||||
$newitem['wo'] = "";
|
$newitem['wo'] = "";
|
||||||
$item = Item::create($newitem);
|
$item = Item::create($newitem);
|
||||||
|
|
||||||
|
if ($request->get('dataImage')) {
|
||||||
$pos = strpos($request->get('dataImage'), ",");
|
$pos = strpos($request->get('dataImage'), ",");
|
||||||
//$head = substr($request->get('dataImage'), 0, $pos);
|
//$head = substr($request->get('dataImage'), 0, $pos);
|
||||||
$image = base64_decode(substr($request->get('dataImage'), $pos + 1), true);
|
$image = base64_decode(substr($request->get('dataImage'), $pos + 1), true);
|
||||||
|
@ -65,6 +66,8 @@ class ItemController extends Controller
|
||||||
mkdir('staticimages', 0755, true);
|
mkdir('staticimages', 0755, true);
|
||||||
file_put_contents('staticimages/' . $hash, $image);
|
file_put_contents('staticimages/' . $hash, $image);
|
||||||
$file = File::create(array('hash' => $hash, 'iid' => $item['iid']));
|
$file = File::create(array('hash' => $hash, 'iid' => $item['iid']));
|
||||||
|
$item['file'] = $hash;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return response()->json($item, 201);
|
return response()->json($item, 201);
|
||||||
}
|
}
|
||||||
|
@ -89,6 +92,7 @@ class ItemController extends Controller
|
||||||
mkdir('staticimages', 0755, true);
|
mkdir('staticimages', 0755, true);
|
||||||
file_put_contents('staticimages/' . $hash, $image);
|
file_put_contents('staticimages/' . $hash, $image);
|
||||||
$file = File::create(array('hash' => $hash, 'iid' => $item['iid']));
|
$file = File::create(array('hash' => $hash, 'iid' => $item['iid']));
|
||||||
|
$item['file'] = $hash;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return response()->json($item, 200);
|
return response()->json($item, 200);
|
||||||
|
|
Loading…
Reference in a new issue