当前位置: 首页 > 图文教程 > 网络编程 > PHP > 以文本方式上传二进制文件的PHP程序

PHP
checkbox向php传输数据的一点总结
PHP5在IIS 6下的安装
debian配置PHP5+MYSQL+Apache
httpd2+mod_perl-2+php4+openssl0安装
php 命令行参数详解及应用
网站开发流程及各岗位职责
Linux新手入门常用命令大全
HTTP参考
初学PHP的18个基础例程
手工注射php学习
PHP 中dirname(_file_)
php开发wap常用技巧
VML绘图板①主控--VMLgraph.htm
VML绘图板③资源--VMLgraph.xml
VML绘图板④简化的服务器端--server.php、server.asp
VML绘图板⑤浏览--view.php
加快 DHTML 的一组技巧
HTML标签详解
PHP系列基础教程(一)--兔子窝边草
XML轻松学习手册

以文本方式上传二进制文件的PHP程序


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 136 ::
收藏到网摘: n/a

现在有的站点上传文件的时候会自动在文件前面加入Content-type: image/gif等头标,导致二进制文件被破坏。因此,我编写了以文本方式上传二进制文件的PHP程序。
  一共两个文件:index.php,action.php。将要上传的文件的文件名改为test,与这两个文件放在一起,运行index.php,选读取,将读取的所有数据Copy,在远端服务器上面也运行这个程序,Paste到输入框中,选保存。二进制文件就被上传了。
index.php
---------------------------------------------------------
<html>
<head>
<title>以文本方式上传二进制文件的PHP程序</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#FFFFFF">
<table width="760" border="0" cellspacing="0" cellpadding="0" height="25">
<tr>
<td>
<div align="center"><b>图片上传</b></div>
</td>
</tr>
</table>
<table width="760" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<form name="form" method="post" action="action.php" target="_blank">
<div align="center">
<textarea name="pic" cols="80" rows="15"></textarea>
<br>
<input type="radio" name="view" value="0" checked>
保存  
<input type="radio" name="view" value="1">
试看  
<input type="radio" name="view" value="2">
读取<br>
<input type="submit" name="OK" value=" 确 定 ">
 
<input type="reset" name="RESET" value=" 取 消 ">
</div>
</form>
</td>
</tr>
</table>
</body>
</html>
---------------------------------------------------------
action.php
---------------------------------------------------------
<?