-
- //-----------------
- //文件名
- $filename = "test.swf";
- //打开文件
- $rs = fopen($filename, "r");
- //读取文件的数据
- $str = fread($rs, filesize($filename));
- //设置swf头文件
- $head = substr($str, 0, 8);
- $head[0] = 'F';
- //获取swf文件内容
- $body = substr($str, 8);
- //压缩文件内容,使用最高压缩级别9
- $body = gzcompress($body, 9);
- //合并文件头和内容
- $str = $head . $body;
- //关闭读取的文件流
- fclose($rs);
- //创建一个新的文件
- $ws = fopen("create.swf", "w");
- //写文件
- fwrite($ws, $str);
- //关闭文件留
- fclose($ws);
- //-------------------
- ?>
复制代码
2,在线解压缩swf文件
-
- //-------------------
- //文件名
- $filename = "1000109.swf";
- //打开文件
- $rs = fopen($filename, "r");
- //读取文件的数据
- $str = fread($rs, filesize($filename));
- //设置swf头文件
- $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);*/
- //获取swf文件内容
- $body = substr($str, 8);
- //解压缩文件内容
- $body = gzuncompress($body);
- //合并文件头和内容
- $str = $head . $body;
- //关闭读取的文件流
- fclose($rs);
- //创建一个新的文件
- $ws = fopen("create.swf", "w");
- //写文件
- fwrite($ws, $str);
- //关闭文件留
- fclose($ws);
- //-------------------
- ?>
复制代码
|