CopyPastor

Detecting plagiarism made easy.

Score: 1.8853968418735059; Reported for: String similarity, Exact paragraph match Open both answers

Possible Plagiarism

Plagiarized on 2019-08-15
by b8x

Original Post

Original - Posted on 2014-11-17
by Latheesan



            
Present in both answers; Present only in the new answer; Present only in the old answer;

Take a look at the Laravel Helpers documentation: http://laravel.com/docs/4.2/helpers
If you want a link to your asset, you can do it like this:
$download_link = link_to_asset('file/example.png');
----
If the above method does not work for you, then you can implement a fairly simple Download route in **app/routes.php** which looks like this:
*Note this example assumes your files are located in **app/storage/file/** location*
// Download Route Route::get('download/{filename}', function($filename) { // Check if file exists in app/storage/file folder $file_path = storage_path() .'/file/'. $filename; if (file_exists($file_path)) { // Send Download return Response::download($file_path, $filename, [ 'Content-Length: '. filesize($file_path) ]); } else { // Error exit('Requested file does not exist on our server!'); } }) ->where('filename', '[A-Za-z0-9\-\_\.]+');
Usage: http://your-domain.com/download/example.png
This will look for a file in: app/storage/file/example.png (if it exists, send the file to browser/client, else it will show error message).
P.S. `'[A-Za-z0-9\-\_\.]+` this regular expression ensures user can only request files with name containing `A-Z` or `a-z` (letters), `0-9` (numbers), `-` or `_` or `.` (symbols). Everything else is discarded/ignored. This is a safety / security measure....
Take a look at the Laravel Helpers documentation: http://laravel.com/docs/4.2/helpers
If you want a link to your asset, you can do it like this:
$download_link = link_to_asset('file/example.png');
----
**Edit**
If the above method does not work for you, then you can implement a fairly simple Download route in **app/routes.php** which looks like this:
*Note this example assumes your files are located in **app/storage/file/** location*
// Download Route Route::get('download/{filename}', function($filename) { // Check if file exists in app/storage/file folder $file_path = storage_path() .'/file/'. $filename; if (file_exists($file_path)) { // Send Download return Response::download($file_path, $filename, [ 'Content-Length: '. filesize($file_path) ]); } else { // Error exit('Requested file does not exist on our server!'); } }) ->where('filename', '[A-Za-z0-9\-\_\.]+');
Usage: http://your-domain.com/download/example.png
This will look for a file in: app/storage/file/example.png (if it exists, send the file to browser/client, else it will show error message).
P.S. `'[A-Za-z0-9\-\_\.]+` this regular expression ensures user can only request files with name containing `A-Z` or `a-z` (letters), `0-9` (numbers), `-` or `_` or `.` (symbols). Everything else is discarded/ignored. This is a safety / security measure....

        
Present in both answers; Present only in the new answer; Present only in the old answer;