Jump to content

Download button


jessnoonyes

Recommended Posts

I want to make a "download" button on my website that when pressed will download a file from my server.  This is the code that I have:

 

<?php

$filename = "Book7_backup4.exe";

 

header("Content-Length: " . filesize($filename));

header('Content-Type: application/octet-stream');

header('Content-Disposition: attachment; filename=Book7_backup4');

 

readfile($filename);

?>

 

But when I test it this is the message that I get:

 

Warning: filesize() [function.filesize]: Stat failed for Book7_backup4.exe (errno=2 - No such file or directory) in /home/waldronf/public_html/maintenance-business/download.php on line 4

 

Warning: Cannot modify header information - headers already sent by (output started at /home/waldronf/public_html/maintenance-business/download.php:4) in /home/waldronf/public_html/maintenance-business/download.php on line 4

 

Warning: Cannot modify header information - headers already sent by (output started at /home/waldronf/public_html/maintenance-business/download.php:4) in /home/waldronf/public_html/maintenance-business/download.php on line 5

 

Warning: Cannot modify header information - headers already sent by (output started at /home/waldronf/public_html/maintenance-business/download.php:4) in /home/waldronf/public_html/maintenance-business/download.php on line 6

 

Warning: readfile(Book7_backup4.exe) [function.readfile]: failed to open stream: No such file or directory in /home/waldronf/public_html/maintenance-business/download.php on line 8

 

 

What does that mean?  Do you know how I can fix it?

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/54473-download-button/
Share on other sites

Warning: filesize() [function.filesize]: Stat failed for Book7_backup4.exe (errno=2 - No such file or directory) in /home/waldronf/public_html/maintenance-business/download.php on line 4

 

Are you sure the file is spelled that way, remember calling files is CaSeSeNSiTiVe.

 

Also check that the file is in deed located at /home/waldronf/public_html/mainenance-business/

 

Link to comment
https://forums.phpfreaks.com/topic/54473-download-button/#findComment-269454
Share on other sites

Now this is the error I get when I type an absolute path:

 

Parse error: syntax error, unexpected '/' in /home/waldronf/public_html/maintenance-business/download.php on line 5

 

yeah I made sure I typed the file name in right, with the right capitalization.  And that is where it's located.  This is driving me nuts

Link to comment
https://forums.phpfreaks.com/topic/54473-download-button/#findComment-269455
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.