Skip to content

Commit

Permalink
add extenstion
Browse files Browse the repository at this point in the history
  • Loading branch information
alihardan committed Apr 10, 2024
1 parent eaf1eea commit d51f060
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/Http/Controllers/GameController.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public function store(Request $request)
foreach ($request->photos as $photo) {
if (isset($photo["dataURL"]))
$game->addMediaFromBase64($photo["dataURL"])
->usingFileName(str_replace('/tmp/', '', tempnam(sys_get_temp_dir(), 'media-library')) . '.jpg')
->toMediaCollection();
}

Expand Down Expand Up @@ -92,7 +93,7 @@ public function update(Request $request, Game $game)
// Upload photos
foreach ($request->photos as $photo) {
if (isset($photo["dataURL"]))
$game->addMediaFromBase64($photo["dataURL"])->toMediaCollection();
$game->addMediaFromBase64($photo["dataURL"])->usingFileName(str_replace('/tmp/', '', tempnam(sys_get_temp_dir(), 'media-library')) . '.jpg')->toMediaCollection();
}
}

Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/ItemController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public function store(Request $request)
foreach ($request->photos as $photo) {
if (isset($photo["dataURL"]))
$item->addMediaFromBase64($photo["dataURL"])
->usingFileName(str_replace('/tmp/', '', tempnam(sys_get_temp_dir(), 'media-library')) . '.jpg')
->toMediaCollection();
}

Expand Down Expand Up @@ -89,7 +90,7 @@ public function update(Request $request, Item $item)
// Upload photos
foreach ($request->photos as $photo) {
if (isset($photo["dataURL"]))
$item->addMediaFromBase64($photo["dataURL"])->toMediaCollection();
$item->addMediaFromBase64($photo["dataURL"])->usingFileName(str_replace('/tmp/', '', tempnam(sys_get_temp_dir(), 'media-library')) . '.jpg')->toMediaCollection();
}
}

Expand Down

0 comments on commit d51f060

Please sign in to comment.