当前位置:首页 > 设计在线 > 网页设计 > WAP > 用PHP实现手机对jar,jad文件的下载

用PHP实现手机对jar,jad文件的下载

点击次数:31 次 发布日期:2008-11-22 11:08:04 作者:源代码网
源代码网推荐

 
如果我们需要在站点提供jar和jad的手机下载,就必须在服务器设置两个MIME
jad:
text/vnd.sun.j2me.app-descriptor
jar:
application/java-archive
而对于一般的虚拟主机来说,我们客户是无法设置的。。
所以,我们必须借助PHP里的header来实现。。

文件:
------------------------
test.jad
test.jad.php
test.jar
test.jar.php
------------------------

修改文件--------
test.jad:
我们先打开,找到这么一行。。
MIDlet-Jar-URL: test.jar
该行的作用是引导手机下载。。
我们现在把它改为test.jar.php

test.jad.php:

<?php
$file_url="test.jad";
$handle=fopen($file_url,"r");
header("Content-Type:text/vnd.sun.j2me.app-descriptor");
echo fread($handle,filesize($file_url));
fclose($handle);
?>

test.jar.php:

<?php
$file_url="test.jar";
$handle=fopen($file_url,"r");
header("Content-Type:application/java-archive");
echo fread($handle,filesize($file_url));
fclose($handle);
?>

---------------------------------------

源代码网供稿.
网友评论 (0)
会员中心
设计在线
本站推荐
设计在线之精华