Repo for the search and displace core module including the interface to select files and search and displace operations to run on them. https://searchanddisplace.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
952 B

  1. <?php
  2. namespace App\Http\Controllers;
  3. use Illuminate\Contracts\Container\BindingResolutionException;
  4. use Illuminate\Http\JsonResponse;
  5. use Illuminate\Support\Facades\Storage;
  6. class FileController extends Controller
  7. {
  8. /**
  9. *
  10. * @return JsonResponse
  11. *
  12. * @throws BindingResolutionException
  13. */
  14. public function create(): JsonResponse
  15. {
  16. $file = request()->file('file');
  17. $filename = time() . $file->getClientOriginalName();
  18. $path = Storage::putFileAs('files/', $file, $filename);
  19. return response()->json([
  20. 'file' => $file->getClientOriginalName(),
  21. 'id' => $filename,
  22. 'path' => $path
  23. ]);
  24. }
  25. /**
  26. *
  27. * @param string $id
  28. *
  29. * @return JsonResponse
  30. *
  31. * @throws BindingResolutionException
  32. */
  33. public function get(string $id): JsonResponse
  34. {
  35. return response()->json(['success']);
  36. }
  37. }