PHP File Download error
Wrote a file to download the program
PHP Code
function Download_file ($filename) {//below to provide the download if (file_exists ($filename)) { $file = fopen ($filename); Header (' Content-description:file Transfer '); Header (' Content-type:application/octet-stream '); Header (' content-disposition:attachment; Filename= '. basename ($filename)); Header (' content-transfer-encoding:binary '); Header (' expires:0 '); Header (' cache-control:must-revalidate '); Header (' Pragma:public '); Header (' Content-length: '. FileSize ($filename). ' bytes '); Ob_clean (); Flush (); ReadFile ($filename); Fclose ($file); return true; }else{echo ("The File not exist"); return false;}//above to provide the download}
However, there is no feature to download. The file has been generated in the previous step. But if I change the return to True to exit the download function can be implemented, but after the file download I also have to do other functions. Ask the gods, what's going on? I see the download example on the Internet is not to say that we need to exit.
------Solution--------------------
See where you call this function, check where it is called, where is there a problem?
------Solution--------------------
Here's the thing:
PHP code
if (Download_file ($filename)) {#下面的操作}else{#错误提示}
------Solution--------------------
discussion
wrote a file download program PHP code
Function Dow Nload_file ($filename) {
//below to provide the download
if (file_exists ($filename))
{
$file ...
------Solution--------------------
discussion
Reference:
this:
PHP code
if (Download_file ($filename)) {
#下面的操作
}else{
#错误提示
}
I don't know what you're talking about. Do you want to omit the return? Return omitted I can't run
------Solution--------------------
Your function return false is equivalent to Preventdefault not submitting the form
When a reply is satisfied, such as checking that the field is non-empty and then return true; The page does not jump until it calls your action
This is the form submission common blocking exception submission method