<?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>
时间: 2024-10-28 22:40:07