Under the guidance of an expert, the files downloaded from the server are empty. Else & quot; open the file; & nbsp; if (! File_exists ($ file_name.
[Code = PHP] [/code]
// Define the image as a variable first;
$ File_name = "QQ20120828234328.png ";
// Open the file;
If (! File_exists ($ file_name )){
Echo "the file does not exist ";
Return;
}
$ Fp = fopen ($ file_name, "r ");
// Obtain the size of the downloaded object
$ File_size = filesize ($ file_name );
// Download the required header file;
// Data download method;
Header ("Content-type: application/octet-stream ");
// Downloads are returned in bytes;
Header ("Accept-ranges: bytes ");
// Size of the downloaded object
Header ("Accept-length: $ file_size ");
// The dialog box popped up by the client, with the corresponding file name.
Header ("Content-Disposition: attachment; filename =". $ file_name );
// Send data back to the client
// Define the text stream
$ Buffer = 1024;
// This statement is used to determine whether the object is ended.
While (! Feof ($ fp )){
// Read text data
$ File_data = fread ($ fp, $ buffer );
// Send some data back to the browser;
}
// Close the file;
Fclose ($ fp );
------ Solution --------------------
// This statement is used to determine whether the object is ended.
While (! Feof ($ fp )){
// Read text data
$ File_data = fread ($ fp, $ buffer );
// Send some data back to the browser;
}
Where are the statements that send some data back to the browser?
------ Solution --------------------
$ File_data = fread ($ fp, $ buffer );
What about echo?