dimanche 8 mai 2022

How to upload TAR.GZ file from Laravel

I am trying to send a tar.gz file from Laravel as a response, but it is not working properly. What is the error in the code? Here $filepath is the absolute path to the tar.gz file.

if(file_exists($filepath)) {
        $file = File::get($filepath);
        $response = Response::make($file, 200);
        $response->header('Content-Type', mime_content_type($filepath));
        $response->header('Content-Length', filesize($filepath));
        $response->header('Pragma', 'public');
        $response->header('Content-Disposition', 'attachment; filename="sample.tar.gz"');

        return $response;
        
    }
    else {
        return $this->response->array(array('error' => 'Could not be downloaded, try again'));
    }


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire