fix image upload

This commit is contained in:
j3d1 2019-12-23 12:19:45 +01:00
parent 59c245232b
commit 84353dd356

View file

@ -52,10 +52,11 @@ class ItemController extends Controller
$newitem['item_uid'] = $uid;
$newitem['wo'] = "";
$item = Item::create($newitem);
$dataImage = $request->get('dataImage');
$image = $request->file('image');
$hash = md5(time());
mkdir('staticimages');
file_put_contents('staticimages/'.$hash, base64_decode($dataImage));
if(!file_exists('staticimages'))
mkdir('staticimages',0755, true);
$image->move('staticimages', $hash);
$file = File::create(array('hash' => $hash, 'iid'=> $item['iid']));
return response()->json($item, 201);
}