Created
April 1, 2019 11:12
-
-
Save rrrhys/e468073d97072c983595cd7e35bb5f42 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Route::get('/external_resource', function(\Illuminate\Http\Request $request){ | |
$resource = $request->get("resource"); | |
$options = array('http' => array('user_agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36')); | |
$context = stream_context_create($options); | |
$f = file_get_contents($resource, false, $context); | |
$finfo = new finfo(FILEINFO_MIME); | |
$contenttype = $finfo->buffer($f); | |
header("Content-Type: " . $contenttype); //HTTP 1.1 | |
echo $f; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment