fix image upload
This commit is contained in:
parent
59c245232b
commit
84353dd356
1 changed files with 4 additions and 3 deletions
|
@ -52,10 +52,11 @@ class ItemController extends Controller
|
||||||
$newitem['item_uid'] = $uid;
|
$newitem['item_uid'] = $uid;
|
||||||
$newitem['wo'] = "";
|
$newitem['wo'] = "";
|
||||||
$item = Item::create($newitem);
|
$item = Item::create($newitem);
|
||||||
$dataImage = $request->get('dataImage');
|
$image = $request->file('image');
|
||||||
$hash = md5(time());
|
$hash = md5(time());
|
||||||
mkdir('staticimages');
|
if(!file_exists('staticimages'))
|
||||||
file_put_contents('staticimages/'.$hash, base64_decode($dataImage));
|
mkdir('staticimages',0755, true);
|
||||||
|
$image->move('staticimages', $hash);
|
||||||
$file = File::create(array('hash' => $hash, 'iid'=> $item['iid']));
|
$file = File::create(array('hash' => $hash, 'iid'=> $item['iid']));
|
||||||
return response()->json($item, 201);
|
return response()->json($item, 201);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue