[求助]文件上传 |
这个程序能上传.但是上传的文件没有扩展名.请大家看看怎么回事.
==================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>
请高手给我该该.
请高手讲讲上传文件的实现方法.
有程序更高
谢谢^_^ |
|
|