42618

Laravel: Storage not putting file inside public folder

<h3>Question</h3>

When I use:

Storage::putFile('documents', $content, 'public');

I expect the folder structure inside public directory, like:

+ +-- storage +--|-- app +--|--|-- public +--|--|--|-- documents +--|--|--|--|-- XyZ.pdf +

Instead of:

+ +-- storage +--|-- app +--|--|-- documents +--|--|--|-- XyZ.pdf +--|--|-- public +

So, to force storage at "right" place I need to explicit put:

Storage::putFile('public/documents', $content, 'public');

What returns me a path that I'm not able to save at database because its values is "public/documents/xyz.pdf" and will not work properly with asset() helper.

How to use Storage facade to put files inside storage/app/public?


<h3>Answer1:</h3>

This isn't explicity in the docs.

Looking at config/filesystems.php, we have a public disk. Just use it:

Storage::disk('public')->put('documents', $content);

来源:https://stackoverflow.com/questions/48513546/laravel-storage-not-putting-file-inside-public-folder

Recommend

  • How to find the index of the minimum value between two specific columns of a matrix with Rcpp?
  • Rails 4: Using PostgreSQL function in order causes error in query due to the includes table not bein
  • How to save a image coded in Data-URI?
  • How to make html video autoplay on phones and tablets?
  • Git branch experiment
  • how to animate two continuous popup windows with jquery mobile?
  • Get frequency distribution of a decimal range in MySQL
  • Java Swing FocusTraversalPolicy Issue
  • Extract Data from a Web Page - using VBA
  • How to use OPENXML to load XML data into existing SQL Table?
  • How can I return more than one value from a method in C#
  • search bar getting disappeared in ios UIsearchcontroller
  • get value using jquery
  • pass sessionid through jquery ajax call to php
  • build an API for streaming audio/video from GridFS mongodb
  • How to convert SVG to jVectorMap format
  • Can I switch the 'connected' user within an sql script that is sourced by mysql?
  • Hibernate Idempotent Update
  • Gitlab: copy project to other git lab repository
  • Azure NodeJS Error: ENOENT, open 'D:\\home\\site\\wwwroot\\bin\\views\\'
  • Selenium Webdriver IE could not find element
  • VB.net Service Programming and using TCP Sockets
  • Boolean filter using a timestamp value on a dataframe in Python
  • AWS RDS Parameter Group not changing MySQL encoding
  • Javascript inside HTML import not affecting imported HTML
  • .Net core Hosted Services guaranteed to complete
  • opencv deskewing a contour
  • How to define a custom accuracy in Keras to ignore samples with a particular gold label?
  • Slice assignment to tensorflow variable
  • C# code can't “see” the methods in my C++ dll
  • flex tree gets chopped even after using scroll bar
  • Copy and paste data from multiple workbooks to a worksheet in another Workbook
  • Wireshark Display Filter for Unique Source/Destination IP and Protocol
  • Year over Year Stats from a Crossfilter Dataset
  • Create an average of multiple excel chart without the data source
  • Neo4j…how to get a visual representation of my data?
  • Drag and drop unicode TText in DelphiXe4
  • What is the best way to cache and reuse immutable singleton objects in Java?
  • Jersey serializes character value to ASCII equivalent numeric string
  • Firebase: How to read from external DB?