继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

UploadedFile.php

Qyouu
关注TA
已关注
手记 489
粉丝 88
获赞 414

<?php

 

namespace Illuminate\Http;

 

use Illuminate\Support\Traits\Macroable;

use Symfony\Component\HttpFoundation\File\UploadedFile as SymfonyUploadedFile;

// more name space and trait

class UploadedFile extends SymfonyUploadedFile

{

    use Macroable;// use trait

 

    /**

     * Get the fully qualified path to the file.

     *

     * @return string

     */

    public function path()

    {

        return $this->getRealPath();

    }// get path ,then use the real path

 

    /**

     * Get the file's extension.

     *

     * @return string

     */

    public function extension()

    {

        return $this->guessClientExtension();

    }// get extension

 

    /**

     * Get a filename for the file that is the MD5 hash of the contents.

     *

     * @return string

     */

    public function hashName()

    {

        return md5_file($this->path()).'.'.$this->extension();// md5_file

    }//Get a filename for the file that is the MD5 hash of the contents.

   // get a type of the md5 about file

 

    /**

     * Create a new file instance from a base instance.

     *

     * @param  \Symfony\Component\HttpFoundation\File\UploadedFile  $file

     * @return static

     */

    public static function createFromBase(SymfonyUploadedFile $file)

    {

        return $file instanceof static ? $file : new static(

            $file->getPathname(), $file->getClientOriginalName(), $file->getClientMimeType(),

            $file->getClientSize(), $file->getError()

        );// return $file

       // to long

    }// Create a new file instance from a base instance.

}

打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP