PHP is not the same, PHP contains the zlib link library, you can directly use its related functions, the following is the example I wrote compression and compressed SWF file:
Not added to determine whether the SWF file has been compressed, into the need can be based on the first byte of a file is ' F ' or ' C ' to determine
To compress a SWF file:
//--------------------------------------------------------------------------------------------------
Filename
$filename = "test.swf";
Open File
$rs = fopen ($filename, "R");
Reading data from a file
$str = Fread ($rs, FileSize ($filename));
Set SWF header File
$head = substr ($str, 1,8);
$head = "C". $head;
Get SWF file contents
$body = substr ($STR, 8);
Compress the contents of a file using the highest compression level 9
$body = Gzcompress ($body, 9);
Merging file headers and contents
$str = $head. $body;
Close the Read file stream
Fclose ($RS);
Create a new file
$ws = fopen ("create.swf", "w");
Write a file
Fwrite ($ws, $STR);
Close file leave
Fclose ($WS);
//----------------------------------------------------------------------------------------------------
?>
To extract the SWF file:
//----------------------------------------------------------------------------------------------------
Filename
$filename = "test.swf";
Open File
$rs = fopen ($filename, "R");
Reading data from a file
$str = Fread ($rs, FileSize ($filename));
Set SWF header File
$head = substr ($str, 1,8);
$head = "F". $head;
Get SWF file contents
$body = substr ($STR, 8);
Unzip the contents of a file
$body = gzuncompress ($body);
Merging file headers and contents
$str = $head. $body;
Close the Read file stream
Fclose ($RS);
Create a new file
$ws = fopen ("create.swf", "w");
Write a file
Fwrite ($ws, $STR);
Close file leave
Fclose ($WS);
//----------------------------------------------------------------------------------------------------
?>
How's it going? Oh, PHP gives us more than simply "'
http://www.bkjia.com/PHPjc/319856.html www.bkjia.com true http://www.bkjia.com/PHPjc/319856.html techarticle using PHP is not the same, PHP contains the zlib link library, you can directly use its related functions, the following is my writing compression and compressed SWF file example://Not added to determine whether the SWF file has ...