<?php
if(!empty($upload))
{
if(empty($uploadfile))
{
echo $uploadfile;
echo "<script language='javascript'>alert('您还没选择图片呢!怎么上传啊?^_^'); location.href='img.php'</script>";
}
else
{
if($uploadfile_size>102400)
{
echo "<script language='javascript'>alert('您的图片太大,请选择适当的图片!'); location.href='img.php'</script>";
exit;
}
if($uploadfile_type!="image/gif" and $uploadfile_type!="image/pjpeg" and $uploadfile_type!="image/png")
{
echo "<script language='javascript'>alert('请选择gif或jpg或png图片类型!'); location.href='img.php'</script>";
exit;
}
$upfile_path="updates/";
$time=time();
$photo=$time.$uploadfile_name;
$picturename=$upfile_path.$photo;
if(!file_exists($picturename))
{
if(!copy($uploadfile,$picturename))
{
echo "服务器忙,图片上传失败!";
exit;
}
echo "<script language='javascript'>alert('图片上传成功!')</script>";
$upload="";
echo "<meta http-equiv=\"Refresh\" content=\"0;url=$PHP_SELF?picturename=".$picturename."&name=".$photo."\">";
}
else
{
echo "服务器忙,图片上传失败!";
exit;
}
}
}
?>
<html><head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>超级链接</title>
<script language="JavaScript">
<!--
function OkButton()
{
if(document.form1.url.value!="")
{
var a = document.getElementsByName("R1");
if(a[0].checked)tmp="[limg]"+document.form1.url.value+"[/limg]";
if(a[1].checked)tmp="[cimg]"+document.form1.url.value+"[/cimg]";
if(a[2].checked)tmp="[rimg]"+document.form1.url.value+"[/rimg]";
window.opener.document.form1.news_content.value+=" "+tmp;
window.opener.document.form1.news_media.value+=" "+"<?=$name?>";
window.close();
}
}
//--></script></head><body topmargin="0" leftmargin="0" onkeydown="if(event.keyCode==13)OkButton()"> <form method="post" enctype="multipart/form-data" name="form1">
<table cellpadding="0" align="center" cellspacing="0" width="347" height="175" style="font-family: Arial; font-size: 10pt; border-collapse:collapse" bordercolor="#111111">
<tr>
<td height="36" colspan="2">
<p style="margin-left: 4"><font color="#800000">图片链接信息</font></td>
</tr>
<tr>
<td width="78" height="32">
<p align="center">本地图片:</td>
<td width="267" height="32">
<input type="file" name="uploadfile" size="12">
<input type="submit" name="upload" <?php if($picturename)echo "disabled" ?> VALUE="上传">
<font color="#FF0000">(<100K)</font> </td>
</tr>
<tr>
<td width="78" height="32">
<p align="center">图片链接:</td>
<td width="267" height="32">
<input type="text" name="url" value="<? if($picturename)echo $picturename; else echo "http://" ?>" size="34"></td>
</tr>
<tr>
<td width="78" height="32">
<p align="center">对齐方式:</td>
<td width="267" height="32">
<input type="radio" value="left" checked name="R1">左对齐
<input type="radio" value="center" name="R1">居中
<input type="radio" value="right" name="R1">右对齐</td>
</tr>
<tr>
<td height="26" colspan="2" align="center">
<input type="button" value=" 确 定 " onclick="javascript:OkButton()" name="B1">
<input type="button" value=" 取 消 " onclick="window.close()" name="B2"></td>
</tr>
</table>
</form>
</body></html>
if(!empty($upload))
{
if(empty($uploadfile))
{
echo $uploadfile;
echo "<script language='javascript'>alert('您还没选择图片呢!怎么上传啊?^_^'); location.href='img.php'</script>";
}
else
{
if($uploadfile_size>102400)
{
echo "<script language='javascript'>alert('您的图片太大,请选择适当的图片!'); location.href='img.php'</script>";
exit;
}
if($uploadfile_type!="image/gif" and $uploadfile_type!="image/pjpeg" and $uploadfile_type!="image/png")
{
echo "<script language='javascript'>alert('请选择gif或jpg或png图片类型!'); location.href='img.php'</script>";
exit;
}
$upfile_path="updates/";
$time=time();
$photo=$time.$uploadfile_name;
$picturename=$upfile_path.$photo;
if(!file_exists($picturename))
{
if(!copy($uploadfile,$picturename))
{
echo "服务器忙,图片上传失败!";
exit;
}
echo "<script language='javascript'>alert('图片上传成功!')</script>";
$upload="";
echo "<meta http-equiv=\"Refresh\" content=\"0;url=$PHP_SELF?picturename=".$picturename."&name=".$photo."\">";
}
else
{
echo "服务器忙,图片上传失败!";
exit;
}
}
}
?>
<html><head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>超级链接</title>
<script language="JavaScript">
<!--
function OkButton()
{
if(document.form1.url.value!="")
{
var a = document.getElementsByName("R1");
if(a[0].checked)tmp="[limg]"+document.form1.url.value+"[/limg]";
if(a[1].checked)tmp="[cimg]"+document.form1.url.value+"[/cimg]";
if(a[2].checked)tmp="[rimg]"+document.form1.url.value+"[/rimg]";
window.opener.document.form1.news_content.value+=" "+tmp;
window.opener.document.form1.news_media.value+=" "+"<?=$name?>";
window.close();
}
}
//--></script></head><body topmargin="0" leftmargin="0" onkeydown="if(event.keyCode==13)OkButton()"> <form method="post" enctype="multipart/form-data" name="form1">
<table cellpadding="0" align="center" cellspacing="0" width="347" height="175" style="font-family: Arial; font-size: 10pt; border-collapse:collapse" bordercolor="#111111">
<tr>
<td height="36" colspan="2">
<p style="margin-left: 4"><font color="#800000">图片链接信息</font></td>
</tr>
<tr>
<td width="78" height="32">
<p align="center">本地图片:</td>
<td width="267" height="32">
<input type="file" name="uploadfile" size="12">
<input type="submit" name="upload" <?php if($picturename)echo "disabled" ?> VALUE="上传">
<font color="#FF0000">(<100K)</font> </td>
</tr>
<tr>
<td width="78" height="32">
<p align="center">图片链接:</td>
<td width="267" height="32">
<input type="text" name="url" value="<? if($picturename)echo $picturename; else echo "http://" ?>" size="34"></td>
</tr>
<tr>
<td width="78" height="32">
<p align="center">对齐方式:</td>
<td width="267" height="32">
<input type="radio" value="left" checked name="R1">左对齐
<input type="radio" value="center" name="R1">居中
<input type="radio" value="right" name="R1">右对齐</td>
</tr>
<tr>
<td height="26" colspan="2" align="center">
<input type="button" value=" 确 定 " onclick="javascript:OkButton()" name="B1">
<input type="button" value=" 取 消 " onclick="window.close()" name="B2"></td>
</tr>
</table>
</form>
</body></html>
我刚才用Chmod试了一下,结果是没有权限执行这个函数。
另外,我刚才改了一下程序,传到服务器的另一个非NTFS盘上就可以上传图片了。
难道跟NTFS和FAT32也有关吗?