Search
 
SCRIPT & CODE EXAMPLE
 

PHP

symfony how to respond in-memory file

// Generate response
$response = new Response();
$filename = 'yourFileName.txt';

// Set headers
$response->headers->set('Cache-Control', 'private');
$response->headers->set('Content-type', $yourMimeType );
$response->headers->set('Content-Disposition', 'attachment; filename="' . $filename . '";');
$response->headers->set('Content-length',  strlen($yourContentString));

// Send headers before outputting anything
$response->sendHeaders();

// Send content
$response->setContent( $yourContentString );

return $response;
Comment

PREVIOUS NEXT
Code Example
Php :: laravel change value to intger 
Php :: correction of controller 
Php :: apache/2.4.53 (win64) openssl/1.1.1n php/8.1.5 server at localhost port 80 
Php :: multiple laravel site in one directory 
Php :: snippet doctrine orm with types 
Php :: was loaded over https, but requested an insecure xmlhttprequest endpoint laravel 
Php :: New in initializers - PHP 8.1 
Php :: QR CODE FROM CAMCODES 
Php :: php get header language 
Php :: acf if image else display other image 
Php :: laravel view not created using foreign keys 
Php :: laravel collection median 
Php :: order review checkout page reset woocomerce 
Php :: laravel command optional parameter 
Php :: automatically make created_by and updated_by using observer laravel 
Php :: laravel migrate patth 
Php :: Josn_encode php api encoding issue 
Php :: wp plugin handles 
Php :: Comment supprimer les éléments liés à WordPress oEmbed 
Php :: header redirect php 
Php :: call node js jquery http php 
Php :: eager load relationships on an existing model in route laravel 
Php :: export csv file in laravel 
Php :: PHP str_pad — Pad a string to a certain length with another string 
Php :: curl upload image huawei 
Php :: laravel livewire refresh computed property 
Php :: openclassroom php 
Php :: Argument #1 ($baseObject) must be of type DateTimeInterface, string given 
Php :: Laravel docker-compose 404 not found Nginx 
Php :: wp dev tehem support widget 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =