HTML Tutorial


 Forum HomeForum Home   FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
RegisterRegister - Not registered yet? Got something to say? Join HTML Code Tutorial!
Download button issues
Post new topic   Reply to topic    HTML Help Forum Index -> PHP
View previous topic :: View next topic  
Author Message
jessnoonyes



Joined: 06 Jun 2007
Posts: 29

PostPosted: Wed Jun 06, 2007 11:03 am     Download button issues Reply with quote

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!
PayneLess Designs



Joined: 28 Feb 2007
Posts: 1260
Location: Biloxi, MS

PostPosted: Mon Jun 11, 2007 8:56 pm     Reply with quote

Maybe this example will help you simplify your code:

Create a Download Link or Button

Ron
Display posts from previous:   
Post new topic   Reply to topic    HTML Help Forum Index -> PHP All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
HTML Help Archive
Powered by phpBB © 2001, 2005 phpBB Group
HTML Help topic RSS feed 

 
HOSTING / DESIGN
MAKE MONEY

Home
  |   Tutorials   |   Forum   |   Quick List   |   Link Directory   |   About
Copyright ©1997-2002 Idocs and ©2002-2007 HTML Code Tutorial