This topic is locked
[SOLVED]

 Create custom button for download file in view ?

12/1/2019 9:37:34 AM
PHPRunner General questions
D
dirk author

Hello,

I want to make a download button in the view screen.

I enter the following code at the server, but nothing happens.

Can someone say how it is to make a download button in the view screen?



$file = "database_bel.gpx";
$filetype=filetype($file);
$filename=basename($file);
header ("Content-Type: ".$filetype);
header ("Content-Length: ".filesize($file));
header ("Content-Disposition: attachment; filename=".$filename);
readfile($file);
N
Nir Frumer 12/1/2019



Hello,

I want to make a download button in the view screen.

I enter the following code at the server, but nothing happens.

Can someone say how it is to make a download button in the view screen?



$file = "database_bel.gpx";
$filetype=filetype($file);
$filename=basename($file);
header ("Content-Type: ".$filetype);
header ("Content-Length: ".filesize($file));
header ("Content-Disposition: attachment; filename=".$filename);
readfile($file);



hi

this is what I use for .zip files where $descarga is the name of the downloadable and $archive_file_name is the name of the file to download...
header("Content-type: application/zip");

header("Content-Disposition: attachment; filename=$descarga");

header("Pragma: no-cache");

header("Expires: 0");

readfile("$archive_file_name");

exit();
hope it helps,

D
dirk author 12/2/2019



hi

this is what I use for .zip files where $descarga is the name of the downloadable and $archive_file_name is the name of the file to download...
header("Content-type: application/zip");

header("Content-Disposition: attachment; filename=$descarga");

header("Pragma: no-cache");

header("Expires: 0");

readfile("$archive_file_name");

exit();
hope it helps,


Hello,
Thank you to report it, but this also does not work.

The code is well into a custom button below the server, and do nothing.
mvg

Dirk

Admin 12/2/2019

Starting multiple threads asking the same question is a bad idea. See my answer at https://asprunner.com/forums/topic/26936-why-dont-work-this-script-in-server-of-button/