php 文件和表单内容一起上传

<?php
$filename = $_POST['filename'];
$explain = $_POST['explain'];
$upfile = $_FILES['upfile'];
if(is_uploaded_file($upfile['tmp_name']) && $upfile['size']>0){
$filepath = './'.$upfile['name'];
move_uploaded_file($upfile['tmp_name'],$filepath);
$res = mysql_query("INSERT INTO 表(filename,explain,filepath) VALUES('$filename','$explain','$filepath')");
if($res){
echo '添加成功!';
exit();
}
}
?>
<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
<p>
<input type="text" name="filename" id="filename" />
</p>
<p>
<input type="text" name="explain" id="explain" />
</p>
<p>
<input type="file" name="upfile" id="upfile" />
</p>
<p>
<input type="submit" name="button" id="button" value="提交" />
</p>
</form>
上一篇:activiti流程图下发任务报错,不能正常流转到下一个处理步骤


下一篇:code force 401B. Game of Credit Cards