首页 > Web开发 > 详细

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

时间:2015-03-17 10:14:18      阅读:324      评论:0      收藏:0      [点我收藏+]
<?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>

 

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

原文:http://www.cnblogs.com/fenle/p/4343634.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!