search

Home  >  Q&A  >  body text

Should Laravel define the uploaded file directory in storage instead of public?

And public is set to non-writable to be safe
How harmful is uploading files to publi to the system?

给我你的怀抱给我你的怀抱2791 days ago940

reply all(2)I'll reply

  • 巴扎黑

    巴扎黑2017-06-30 10:02:09

    I agree with @chekun’s answer, please read the official document carefully: File Storage

    Public disk# "Public disk" means that your files will be publicly accessible. By default, the public disk uses the local driver and stores the files in the
    storage/app/public directory. For network access, you need to create a symbolic link from public/storage to
    storage/app/public. This convention allows your publicly accessible files to stay in the same directory, so they can be easily shared between different deployment systems, such as
    Envoyer's "non-stop" deployment system.

    You can create symbolic links using the storage:link Artisan command:

    php artisan storage:link Of course, once the file is placed and the symbolic link is created, you can create the URL using the asset helper function:

    echo asset('storage/file.txt');

    reply
    0
  • PHP中文网

    PHP中文网2017-06-30 10:02:09

    laravel default is:

    The public storage directory in the storage configuration is storage/app/public
    Then use php artisan storage:link link to the public directory

    reply
    0
  • Cancelreply