Anyone good with PHP? January 21, 2010 07:56PM | Registered: 15 years ago Posts: 5,075 |
<?php $file = halmer.cer header('Content-Description: File Transfer'); header('Content-Type: application/x-x509-ca-cert'); header('Content-Length: ' . filesize($file)); $bn = basename($file); header("Content-Disposition: attachement;filename=$bn"); readfile($file); ?>
Parse error: syntax error, unexpected T_STRING in /home/a8533703/public_html/install.php on line 6
header('Content-Description: File Transfer');
Re: Anyone good with PHP? January 21, 2010 09:01PM | Registered: 15 years ago Posts: 703 |
Re: Anyone good with PHP? January 21, 2010 09:36PM | Registered: 15 years ago Posts: 405 |
htp://test.com/test.php?test=1&foo=3 --> $test = 1; $foo = 3;
htp://test.com/install.php?file=http://baddomain.com/badfile.exewhich using your code could theoretically force the download of htp://baddomain.com/badfile.exe if the server is not correctly set
Re: Anyone good with PHP? January 21, 2010 11:26PM | Registered: 15 years ago Posts: 5,075 |
Re: Anyone good with PHP? January 21, 2010 11:35PM | Registered: 15 years ago Posts: 703 |
$filename = "halmer.cer"; // I think you need full path !! $shortname = basename( $filename ); $contentType='application/x-x509-ca-cert'; header("Pragma: "); header("Cache-Control: "); header("Content-type: $contentType"); header("Content-Disposition: attachment; filename=\"".$shortname."\""); header("Content-length:".(string)(filesize($filename))); set_time_limit(0); readfile($filename);
Re: Anyone good with PHP? January 21, 2010 11:41PM | Registered: 15 years ago Posts: 5,075 |
Re: Anyone good with PHP? January 22, 2010 05:27PM | Registered: 15 years ago Posts: 5,075 |
Re: Anyone good with PHP? January 22, 2010 06:56PM | Registered: 15 years ago Posts: 703 |
Quote
SifJar
OK, it works on my computer, but not on my mobile phone (which is the while point of this exercise, I'm trying to get it to install a new certificate for Java). On the computer, it downloads the file no problem. But on my phone it gives a PHP error saying the line "set_time_limit(0);" has been disabled for security reasons, then it has the file below that, but it isn't downloading the file, it just displays the contents of the file. Anyone have any idea why this is working on the computer but not on my mobile phone?
Re: Anyone good with PHP? January 22, 2010 07:13PM | Registered: 15 years ago Posts: 5,075 |
Re: Anyone good with PHP? January 22, 2010 07:21PM | Registered: 15 years ago Posts: 703 |
Quote
SifJar
Its on a server yeah, and it works fine on computer, just not on phone...I'll try changing that line thanks. BTW, I also removed the problem line, which removed the error, but still made it echo the file instead of download. Thanks for all your help, if this doesn't work, I'll probably just give up.
Re: Anyone good with PHP? January 22, 2010 07:31PM | Registered: 15 years ago Posts: 703 |
<?php $filename = "halmer.cer"; // I think you need full path !! $shortname = basename( $filename ); $contentType='application/octet-stream'; header("Pragma: "); header("Cache-Control: "); header("Content-type: $contentType"); header("Content-Disposition: attachment; filename=\"".$shortname."\""); header("Content-length:".(string)(filesize($filename))); readfile($filename); exit(0); ?>
Re: Anyone good with PHP? January 22, 2010 07:47PM | Registered: 15 years ago Posts: 5,075 |