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.
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
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?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community