-1

I'm working on project that should create link to download xpi file.

T his is my php code to download file:

$fileName = 'file.xpi';
$size = filesize($fileName);

$fp = fopen($fileName, "rb");
$content = fread($fp, $size);
fclose($fp);

header("Content-length: ".$size);
header("Content-type: application/x-xpinstall");
header("Content-disposition: attachment; filename=".$fileName.";" );
echo $content;

This code work's fine, but the downloaded file is my problem.. when i run, Firefox show this error message:

This add-on could not be installed because it appears to be corrupt.

Both files (that one on server and that one downloaded) have the same information.

file on server

Sive : 14.7 MB (15,509,809 bytes)

Sive on Disk : 14.7 MB (15,511,552 bytes)

download file

Sive : 14.7 MB (15,509,809 bytes)

Sive on Disk : 14.7 MB (15,511,552 bytes)

What should I do?

Ashley Medway
  • 7,151
  • 7
  • 49
  • 71
MajidRamzi
  • 438
  • 2
  • 4
  • 12

1 Answers1

1

Open downloaded file in some kind of text editor like Notepad and check if there are not any plain text PHP-related errors at the beginning of the file.

michal.hubczyk
  • 698
  • 3
  • 9
  • tanx, i forgot to check files in notepad! exist break line at top of the page i create and that one 'Enter' joined to file. exactly to the point. – MajidRamzi Feb 23 '15 at 09:15