Support the ongoing development of Laravel.io →
Configuration Views
Last updated 2 years ago.
0

Here is what my course folder looks like: folder name mobile (directory) slides (directory) data.js mask.js player.css story_content (directory user.js data.swf story.html story.swf

I can not figure out how to get this entire package to load correctly in a view.

0

If they are out of the public folder you will need to call them through php/laravel

So you could setup a route like

Route::get('asset/{file}', [
'uses' => 'AssetController@index', 
'as' => 'asset'
]);

Then in your asset controller you would have

public function index($file)
{
    // permission checks???

    // make sure the user isn't trying to traverse directories
    $basePath = '/foo/bar/baz/'; // this is the root of your assets folder
    $realBasePath = realpath($basePath); // this converts your $basepath into a FQ path
    $userPath = $basePath . $file; // this is the file the user has requested including path
    $realUserPath = realpath($userPath); // this converts the $userPath into a FQ path

    // check if $realUserPath contains $realBasePath
    if ($realUserPath === false || strpos($realUserPath, $realBasePath) !== 0) {
        //Directory Traversal! - BAD
        abort(403);
    } else {
        //Good path!
        // send the file (mod_xsendfile/read_file
    }


    
    
}

You will notice that I have included code to prevent directory traversal - this is to prevent a malicious user traversing up the directory tree and managing to send some of your app code or worse

Last updated 9 years ago.
0

I have never loaded anything like this before. If I place a folder inside say the storage folder. How can I reference a file named story.swf inside my view?

0

Sign in to participate in this thread!

Eventy

Your banner here too?

tpbsv77 tpbsv77 Joined 12 Mar 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.