LocalpicController.php 606 B

123456789101112131415161718192021222324
  1. <?php
  2. namespace app\index\controller;
  3. class LocalpicController extends Base
  4. {
  5. public function index()
  6. {
  7. $pic = input('post.pic', '', 'serach_in');
  8. if (!strpos($pic, '//' . getdomainname())) {
  9. $picfile = explode('/', $pic);
  10. $filename = end($picfile);
  11. $content = file_get_contents($pic);
  12. $save_to = config('filesystem.disks.public.root') . '/' . $filename;
  13. file_put_contents($save_to, $content);
  14. $pic = toimg('public/uploads/' . $filename);
  15. }
  16. return $this->json(['data' => $pic]);
  17. }
  18. }