久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Laravel 5.3 Storage::put 創(chuàng)建一個(gè)包含文件名的目錄

Laravel 5.3 Storage::put creates a directory with the file name(Laravel 5.3 Storage::put 創(chuàng)建一個(gè)包含文件名的目錄)
本文介紹了Laravel 5.3 Storage::put 創(chuàng)建一個(gè)包含文件名的目錄的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我正在使用 Laravel 的文件存儲(chǔ)功能來保存文件:

I'm using Laravel's file storage functionality to save a file:

public function dataPost(Request $request) {

    $fileInForm = 'doc';

    if ($request->hasFile($fileInForm)) {

        $file = $request->file($fileInForm);
        if ($file->isValid()) {

            // Filename is hashed filename + part of timestamp
            $hashedName = hash_file('md5', $file->path());
            $timestamp = microtime() * 1000000;

            $newFilename = $hashedName . $timestamp . '.' . $file->getClientOriginalExtension();

            Storage::disk('local')->put($newFilename, $file);
        }
    }
}

這確實(shí)保存了文件,但保存在與文件同名的目錄中,例如:

This does save the file, but inside a directory named the same as the file, for example:

storage/app/952d6c009.jpg/952d6c009.jpg

storage/app/234234234.jpg/234234234.jpg

這是預(yù)期的嗎?有沒有辦法只存儲(chǔ)文件而不為每個(gè)文件設(shè)置單獨(dú)的目錄?

Is this expected? Is there any way to just store the file without a separate directory for each file?

謝謝!

推薦答案

你需要在第二個(gè)參數(shù)中提供文件內(nèi)容而不是文件對(duì)象,試試這個(gè):

you need to provide the file contents in the second argument not file object, try this:

Storage::disk('local')->put($newFilename, file_get_contents($file));

這篇關(guān)于Laravel 5.3 Storage::put 創(chuàng)建一個(gè)包含文件名的目錄的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Magento products by categories(按類別劃分的 Magento 產(chǎn)品)
Resource interpreted as image but transferred with MIME type text/html - Magento(資源被解釋為圖像但使用 MIME 類型 text/html 傳輸 - Magento)
Is there an event for customer account registration in Magento?(Magento 中是否有客戶帳戶注冊(cè)事件?)
Magento addFieldToFilter: Two fields, match as OR, not AND(Magento addFieldToFilter:兩個(gè)字段,匹配為 OR,而不是 AND)
quot;Error 404 Not Foundquot; in Magento Admin Login Page(“未找到錯(cuò)誤 404在 Magento 管理員登錄頁面)
Get Order Increment Id in Magento(在 Magento 中獲取訂單增量 ID)
主站蜘蛛池模板: 日本高清网站 | 夜夜操夜夜 | 亚洲精品视频免费在线观看 | 国产高潮在线观看 | 黄色一级免费看 | 成人国产精品久久久网站 | 成人在线国产 | 一级黄色a | 一级黄色大片 | 日本加勒比在线 | 98久久| 欧美成人一级片 | 四虎在线播放 | 天天精品| 欧美精品在线播放 | 欧美日韩国产一区二区 | 国产视频一二区 | 黄色大毛片| 成人a视频 | 国产999视频| 亚洲最大黄色网址 | 天天干天天干 | 69er小视频| 久久国产精 | 午夜精品一区二区三区在线播放 | 不卡中文字幕 | 亚洲黄色一级 | 国产日韩精品视频 | 国产第二页 | 国产精品视频久久久 | 久久久国产精品人人片 | 亚洲伊人影院 | av在线天堂 | 黄色一级视频网站 | www.精品国产 | 中文字幕在线一区二区三区 | 69av在线 | 精品国产一区二区在线观看 | 欧美一级做性受免费大片免费 | 999国产视频| 黄色片视频免费 |