-
- //-----------------
- //File name
- $filename = "test.swf";
- //Open the file
- $rs = fopen($filename, "r");
- //Read file data
- $str = fread($rs, filesize($filename));
- //Set swf header file
- $head = substr( $str, 0, 8);
- $head[0] = 'F';
- //Get the swf file content
- $body = substr($str, 8);
- //Compress the file content, use the highest compression level 9
- $body = gzcompress($body, 9);
- //Merge file header and content
- $str = $head . $body;
- //Close the read file stream
- fclose($rs);
- //Create A new file
- $ws = fopen("create.swf", "w");
- //Write the file
- fwrite($ws, $str);
- //Close the file
- fclose($ws);
- //-------------------
- ?>
Copy the code
2, decompress the swf file online
-
- //------------------
- //File name
- $filename = "1000109.swf";
- // Open the file
- $rs = fopen($filename, "r");
- //Read the file data
- $str = fread($rs, filesize($filename));
- //Set the swf header file
- $head = substr($str, 0, 8);
- //$head = 'F' . $head;
- $head[0] = 'F';
- /*$head[1] = ('W');
- $head[2] = ('S');
- //$head[3] = version;
- $head[4] = ($str % 256);
- $head[5] = ($str / 256 % 256);
- $head[6] = ($str / 256 / 256 % 256);
- $head[7] = ($str / 256 / 256 / 256 % 256);*/
- //Get swf file Content
- $body = substr($str, 8);
- //Decompress file content
- $body = gzuncompress($body);
- //Merge file header and content
- $str = $head . $body;
- / /Close the read file stream
- fclose($rs);
- //Create a new file
- $ws = fopen("create.swf", "w");
- //Write the file
- fwrite($ws, $str);
- //Close the file
- fclose($ws);
- //------------------
- ?>
Copy code
|