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['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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue