Php file download code. $ F_idisset ($ _ GET [id])? $ _ GET [id]:; $ t_idisset ($ _ GET [tid])? $ _ GET [tid]:; $ t_na ($ t_su_photo;} elseif ($ t_id2) {$ t_na $ f_id = isset ($ _ GET ['id'])? $ _ GET ['id']: '';
$ T_id = isset ($ _ GET ['tid'])? $ _ GET ['tid']: '';
$ T_na = ($ t_id = 1 )? "Su_photo": "su_video ";
If ($ t_id = 1 ){
$ T_na = 'Su _ photo ';
} Else if ($ t_id = 2 ){
$ T_na = 'Su _ video ';
} Else {
$ T_na = 'Su _ cert ';
}
$ SQL = "select * from $ t_na where id = $ f_id and uid = '". $ _ SESSION ['xm']. "'";
$ Result = mysql_query ($ SQL) or exit ("system busy ...");
If (! Mysql_num_rows ($ result) {exit ("
Alert ('record does not exist! '); History. back ();
");}
$ Rs = mysql_fetch_object ($ result );
$ File_name = substr ($ rs-> path, strrpos ($ rs-> path, "/") + 1 );
$ File_dir = substr ($ rs-> path, 0, strlen ($ rs-> path)-strlen ($ file_name ));
$ File_dir = realpath (str_replace ('../', '', $ file_dir ))."\";
$ Rpath = $ file_dir. $ file_name;
If (! File_exists ($ rpath) {// check whether the file exists
Exit ("
Alert ('file not found! '); History. back ();
");
} Else {
$ Tent = substr ($ rpath, strrpos ($ rpath, ".") + 1 );
$ File = fopen ($ rpath, "r"); // open the file
Header ("Content-type:". headertype ($ tent )."");
Header ("Accept-Ranges: bytes ");
Header ("Accept-Length:". filesize ($ file_dir. $ file_name ));
Header ("Content-Disposition: attachment; filename =". $ file_name );
Echo fread ($ file, filesize ($ file_dir. $ file_name ));
Fclose ($ file );
Exit ("
Alert ('Download complete! '); History. back ();
");
}
Function headertype ($ type ){
Switch ($ type ){
Case 'GIF ':
Return 'image/GIF ';
Break;
Case 'jpg ':
Return 'image/pjpeg ';
Break;
Case 'bmp ':
Return 'image/bmp ';
Break;
Case 'PNG ':
Return 'image/x-png ';
Break;
Case 'txt ':
Return 'application/octet-stream ';
Break;
Case 'Zip ':
Return 'application/x-zip-compressed ';
Break;
Case 'rar ':
Return 'application/x-rar-compressed ';
Break;
Case 'Doc ':
Return 'application/msword ';
Break;
Case 'swf ':
Return 'application/x-shockwave-Flash ';
Break;
Case 'wma ':
Return 'audio/x-ms-wma ';
Break;
Case 'rm ':
Return "application/vnd. rn-realmedia ";
Break;
Case 'mp3 ':
Return "audio/mp3 ";
Break;
Default:
Return 'text/plain ';
}
}
?>
Vertex = isset ($ _ GET ['id'])? $ _ GET ['id']: ''; $ t_id = isset ($ _ GET ['tid'])? $ _ GET ['tid']: ''; $ t_na = ($ t_id = 1 )? Su_photo: su_video; if ($ t_id = 1) {$ t_na = 'Su _ photo ';} else if ($ t_id = 2) {$ t_na...