21,891
社区成员
发帖
与我相关
我的任务
分享
<?php
include("include/common.inc");
if($cancelit)
{
header("Location:welcome.php");
exit;
}
function do_upload()
{
global $userfile,$userfile_size,$userfile_name,$userfile_type;
global $local_file,$error_msg;
global $HTTP_REFERER;
if($userfile=="none")
{
$error_msg="没有选择上车文件!";
return;
}
if($userfile_size>200000)
{
$error_msg="对不起,上传的文件太大!";
return;
}
$upload_dir="photos";
$local_file="$upload_dir/$userfile_name";
if(file_exists($local_file))
{
$error_msg="对不起,该文件已存在!";
return;
};
//
move_uploaded_file($_FILES['userfile']['tmp_name'],$local_file);
echo "文件上传成功!";
echo "<A HREF=\"$HTTP_REFERER\">Go Back</A><BR>";
}
$title="上传图片";
include("include/header.inc");
if(empty($userfile)||$userfile=="none")
{
?>
<FORM ACTION="<?php echo "$PHP_SELF";?>" ENCTYPE="multipart/form-data" METHOD=POST>
<INPUT TYPE="HIDDEN" NAME="MAX_FILE_SIZE" VALUE="2000000">
<INPUT TYPE="FILE" NAME="userfile" SIZE="24" MAXLENGTH="80">
<BR><BR>
<INPUT TYPE="SUBMIT" VALUE="上传文件" NAME="sendit">
<INPUT TYPE="SUBMIT" VALUE="取消" NAME="cancelit"><BR>
</FORM>
<I><FONT SIZE="2">(You my notice a slight delay we upload your file.)</FONT></I>
<?}
else
{
if($error_msg)
{
echo "<B>$error_msg</B><BR><BR>";}
if($sendit)
{
do_upload();
}
}
include("include/footer.inc");
?>