1234567891011121314151617181920212223242526272829303132333435363738 |
- <?php
- namespace app\Repositories\Eloquent;
- use App\Repositories\Eloquent\BaseRepository;
- use App\Repositories\Contracts\UploadInterface;
- use Illuminate\Support\Facades\Storage;
- /**
- *
- * @author lilin
- *
- */
- class UploadFacadeRepository extends BaseRepository implements UploadInterface
- {
- public function pic($file, $dst = 'pics')
- {
- $this->setLog(self::TYPENAME. '图片开始', $this->startTime());
-
- $picInfo = getimagesize($file);
-
- if (! $picInfo) {
- $this->error()->notImageFile();
- }
-
- $srcPath = $file->getPathname();
- $extension = $file->getClientOriginalExtension();
- $fileName = time() . rand() . '.' . $extension;
- $dstPath = $dst . '/' . date('Y') . '/' . date('m');
- $size = $file->getSize();
-
- $path = Storage::putFile($dstPath, $file);
-
- $this->setLog(self::TYPENAME. '图片结束', $this->startTime, [$path]);
- return $this->response($path);
- }
-
- }
|