演示地址:http://classie.w11.cndns.com/madmin/vod_5.php
下面是源码
<table width="600" border="0" align="center" cellspacing="0">
<form action="" id="form1" name="form1" method='post' enctype='multipart/form-data'>
<tr>
<td width="318" align="center">标题:
<input type="text" name="textfield" />
</td>
<td width="278"><select name="select">
<option value="0">简体中文</option>
<option value="1">英文</option>
<option value="2">繁体中文</option>
</select></td>
</tr>
<tr>
<td colspan="2" align="center">图片:
<input type='file' name='file_img' class='input1' size=32></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="hidden" id="content" name="content" value="" style="display:none" /><input type="hidden" id="content___Config" value="" style="display:none" />
<iframe id="content___Frame" src="FCKEditor/fckeditor.html?InstanceName=content&Toolbar=Default" width="533" height="200" frameborder="0" scrolling="no"></iframe></td>
</tr>
<tr>
<td colspan="2" align="center"><label>
<input type="submit" name="Submit" value="提交" />
</label></td>
</tr>
</form>
</table>
<?php
$updir="../UploadFile/";
if($_SERVER["REQUEST_METHOD"]=="POST")
{
$file_img=$_POST['file_img'];
$content=$_POST['content'];
$name=$_FILES["file_img"]["name"];
$type=$_FILES["file_img"]["type"];
$size=$_FILES["file_img"]["size"];
if($name=="")
{
echo"<script>alert('请先选择要上传的图片文件!');window.history.back();</script>";
}
$tmp_name=$_FILES["file_img"]["tmp_name"];
if($type!="image/pjpeg" && $type!="image/jpeg" && $type!="image/gif")
{
echo"<script>alert('上传文件只可以是JPEG或GIF类型的!');window.history.back();</script>";
exit;
}
if(!$size>$maxsize)
{
echo"<script>alert('上传文件大小不能超过500K!');window.history.back();</script>";
exit;
}
if(file_exists($updir.$name))
{
echo"<script>alert('服务器上已有同名文件!');window.history.back();</script>";
exit;
}
if(copy($tmp_name,$updir.$name))
{
$upd=date("YmjGis").".jpg";
rename($updir.$name,$updir.$upd);
}
if(move_uploaded_file($tmp_name,$updir.$name))
{
if(!is_dir($updir.$name)) {
unlink($updir.$name);
} else {
deldir($fullpath);
}
echo "upd"; }
}
?>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货