Projekt

Obecné

Profil

Stáhnout (1.64 KB) Statistiky
| Větev: | Revize:
1
<?php
2

    
3
namespace Illuminate\Http;
4

    
5
use Illuminate\Support\Traits\Macroable;
6
use Symfony\Component\HttpFoundation\File\UploadedFile as SymfonyUploadedFile;
7

    
8
class UploadedFile extends SymfonyUploadedFile
9
{
10
    use Macroable;
11

    
12
    /**
13
     * Get the fully qualified path to the file.
14
     *
15
     * @return string
16
     */
17
    public function path()
18
    {
19
        return $this->getRealPath();
20
    }
21

    
22
    /**
23
     * Get the file's extension.
24
     *
25
     * @return string
26
     */
27
    public function extension()
28
    {
29
        return $this->guessExtension();
30
    }
31

    
32
    /**
33
     * Get the file's extension supplied by the client.
34
     *
35
     * @return string
36
     */
37
    public function clientExtension()
38
    {
39
        return $this->guessClientExtension();
40
    }
41

    
42
    /**
43
     * Get a filename for the file that is the MD5 hash of the contents.
44
     *
45
     * @param  string  $path
46
     * @return string
47
     */
48
    public function hashName($path = null)
49
    {
50
        if ($path) {
51
            $path = rtrim($path, '/').'/';
52
        }
53

    
54
        return $path.md5_file($this->path()).'.'.$this->extension();
55
    }
56

    
57
    /**
58
     * Create a new file instance from a base instance.
59
     *
60
     * @param  \Symfony\Component\HttpFoundation\File\UploadedFile  $file
61
     * @param  bool $test
62
     * @return static
63
     */
64
    public static function createFromBase(SymfonyUploadedFile $file, $test = false)
65
    {
66
        return $file instanceof static ? $file : new static(
67
            $file->getPathname(),
68
            $file->getClientOriginalName(),
69
            $file->getClientMimeType(),
70
            $file->getClientSize(),
71
            $file->getError(),
72
            $test
73
        );
74
    }
75
}
(6-6/7)