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,15 +56,18 @@ class ItemController extends Controller
|
|||
$newitem['wo'] = "";
|
||||
$item = Item::create($newitem);
|
||||
|
||||
$pos = strpos( $request->get('dataImage') , "," );
|
||||
//$head = substr($request->get('dataImage'), 0, $pos);
|
||||
$image = base64_decode(substr($request->get('dataImage'), $pos+1), true);
|
||||
if($image) {
|
||||
$hash = md5(time());
|
||||
if (!file_exists('staticimages'))
|
||||
mkdir('staticimages', 0755, true);
|
||||
file_put_contents('staticimages/'. $hash, $image);
|
||||
$file = File::create(array('hash' => $hash, 'iid' => $item['iid']));
|
||||
if ($request->get('dataImage')) {
|
||||
$pos = strpos($request->get('dataImage'), ",");
|
||||
//$head = substr($request->get('dataImage'), 0, $pos);
|
||||
$image = base64_decode(substr($request->get('dataImage'), $pos + 1), true);
|
||||
if ($image) {
|
||||
$hash = md5(time());
|
||||
if (!file_exists('staticimages'))
|
||||
mkdir('staticimages', 0755, true);
|
||||
file_put_contents('staticimages/' . $hash, $image);
|
||||
$file = File::create(array('hash' => $hash, 'iid' => $item['iid']));
|
||||
$item['file'] = $hash;
|
||||
}
|
||||
}
|
||||
return response()->json($item, 201);
|
||||
}
|
||||
|
@ -89,6 +92,7 @@ class ItemController extends Controller
|
|||
mkdir('staticimages', 0755, true);
|
||||
file_put_contents('staticimages/' . $hash, $image);
|
||||
$file = File::create(array('hash' => $hash, 'iid' => $item['iid']));
|
||||
$item['file'] = $hash;
|
||||
}
|
||||
}
|
||||
return response()->json($item, 200);
|
||||
|
|
Loading…
Reference in a new issue