首 页   · 站长博客 · 用户注册 · 会员登陆  · 会员排行  ·最新主题  ·最近回复  精华区  版权声明  ·论坛管理
  当前登录身份:游客,请先登录。  笔名: 口令: 验证码:   
楼 主  index »  PHP安装/语法/函数 » [求助]文件上传  


  作者:yzhxiang
  注册时间:2006-09-02
  主题/回复:4/14
  积分:492
  等级:★★☆(五级)
  称号:略有小成

  yzh-xiang@163.co..
  未提供
 

 

 发表:2007-01-27 20:57:58 阅读 2451 次 回复 1 次 得分0  |   字号 字色
[求助]文件上传
这个程序能上传.但是上传的文件没有扩展名.请大家看看怎么回事.
==================upload.htm==============
<htmL>
<head>
<title>upload your file</title>
</head>
<body>
<form action=\"receiver.php\" enctype=\"multipart/form-data\" method=post>
<input type=hidden name=max_file_size value=200000 >
<input type=file name=uploadfile size=\"24\" maxlength=80>
<br><br>
<input type=\"submit\" value=\"upload file\" name=\"sendit\">
<input type=\"submit\" value=\"cancel\" name=\"cancelit\"><br>
</from>
</body>
</html>
==================receiver.php==============
<?php

function do_upload(){
global $uploadfile,$uploadfile_size;
global $local_file,$error_msg;
$uploadfile_type = explode(\",\",$config[\'jpg\']);
If($uploadfile==\"none\"){
$error_msg=\"sorry,no file\";
return;
}

if($uploadfile_size>2000000){
$error_msg=\"sorry,much size\";
return;
}
$the_time=time();
$upload_dir=\"images/\";
$local_file=\"$upload_dir/$the_time\";
if(file_exists(\'$local_file\'))
{
$seq=1;
while(file_exists(\"$upload_dir/$the_time$seq\")){$seq++;}
$local_file=\"$upload_dir/$the_time$seq\";
};
rename($uploadfile,$local_file);
display_page();
}
function  display_page(){
}
?>
<html>
<head>
<title>php</title>
</head>
<body>
<?php
if($error_msg){echo\"<b>$error_msg</b><br><br>\";}
if($sendit){
do_upload();
echo\"file success\";
}
elseif($cancelit){
header(\"location:$some_other_script\");
echo\"wen shban\";
exit;
}else{
some_other_func();
}
  ?>
    </body>
  </html>
  
请高手给我该该. 
请高手讲讲上传文件的实现方法.
有程序更高
谢谢^_^
 
 1#楼  
 
  回复人:yzhxiang
  注册时间:2006-09-02
  主题/回复:4/14
  积分:492
  等级:★★☆(五级)
  称号:略有小成

   
 1#楼 发表于2007-01-27 21:20:06  评分:× 

站长,在你的\" [5][原创]PHP文件上传祖传秘方吐血公布\"中,我看到了源程序.
^+^谢谢了..........
还能给我再讲些上传文件的知识吗?
  页数1/1首页 « 1 » 末页
  发表回复:您还没有登陆,无法发表回复。请先[登陆]

一起PHP技术联盟 主办:一起PHP 联系方式:站长QQ:4304410 QQ群:8423742 20159565 站长博客 E-mail: nqp@nqp.me 执行时间:0.006sec
SimsmaBBS 2008 (v6.0) Developed by 17php.com,Copyright(C)2003-2010 All rights reserved. 副本授权:一起PHP官方专用版