现在有的站点上传文件的时候会自动在文件前面加入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
---------------------------------------------------------
<?
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器