Php 上载文件在此页面中不起作用
它保存数据中的所有内容,但不保存更新文件的名称。它在第17、18、19、20行中显示未定义的索引,在数据库的PIC列中没有显示任何内容,Php 上载文件在此页面中不起作用,php,Php,它保存数据中的所有内容,但不保存更新文件的名称。它在第17、18、19、20行中显示未定义的索引,在数据库的PIC列中没有显示任何内容,subjects\u PIC文件夹中没有存储任何内容 代码如下所示: <?php include('conect.php'); $d = ''; $qre = mysql_query("select * from courses1"); while ($res = mysql_fetch_array($qre)) { $d .='<optio
subjects\u PIC
文件夹中没有存储任何内容
代码如下所示:
<?php
include('conect.php');
$d = '';
$qre = mysql_query("select * from courses1");
while ($res = mysql_fetch_array($qre)) {
$d .='<option value="' . $res['cid'] . '">' . $res['cname'] . '</option>';
}
?>
<?php
include('auth.php');
include('conect.php');
$msg = '';
if (isset($_POST['save'])) {
$course = $_POST['courses1'];
$subjects = $_POST['subjects'];
$name = $_POST['name'];
$file_name = $_FILES['f1']['name'];
$file_type = $_FILES['f1']['type'];
$file_size = $_FILES['f1']['size'];
$file_tmp = $_FILES['f1']['tmp_name'];
$file_path = '../subject_pic/' . $file_name;
move_uploaded_file($file_tmp, $file_path);
mysql_query("INSERT INTO up_file (cid,subid,name,pic)
VALUES ('$course','$subjects','$name','$file_name')");
$msg = '<h3>Record Saved</h3>';
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>subjects</title>
<link rel="stylesheet" type="text/css" href="headerstyle.css" />
<script type="application/javascript" src="prototype.js"></script>
<script type="text/javascript">
function abc()
{
var a = $('courses1').value;
$("k").innerHTML = '<img src="ajax-loader.gif">';
new Ajax.Request("ajax1.php", {
method: 'post',
postBody: "e=" + a,
onComplete: Update_abc
});
}
function Update_abc(req)
{
var data = req.responseText;
$("k").innerHTML = '';
$("k").innerHTML = data;
//alert(data);
}
</script>
</head>
<body>
07/25/2014
<div class="fixx"><?php include('header.php'); ?></div>
<div class="tabl">
<table width="700" border="0">
<tr>
<td>
<form method="post" action="filupload.php">
<table width="700" border="1" cellpadding="10">
<tr>
<td colspan="2"><h3> ADD Files To Subjects | <a href="fil_list.php"> EDIT</a> </h3></td>
</tr>
<tr>
<td colspan="2"><?php echo $msg; ?></td>
</tr>
<tr>
<td width="174"><h4>Select Course </h4></td>
<td width="674"><label for="courses"></label>
<select name="courses1" id="courses1" onchange="abc()">
<option value="">Select Course</option>
<?php echo $d; ?>
</select> </td>
</tr>
<tr>
<td width="174"><h4>Select Subject </h4></td>
<td width="674"><label for="subjects"></label>
<div id="k">
<select name="subjects" id="subjects"><option value="">Select Subject</option></select>
</div> </td>
</tr>
<tr>
<td><h4>File Name</h4></td>
<td><input type="text" name="name" id="name" /></td>
</tr>
<tr>
<td><h4>Upload Pic</h4></td>
<td><label for="f1"></label>
<input type="file" name="f1" id="f1" /></td>
</tr>
<tr>
<td><input type="submit" name="save" id="save" value="Submit" /></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</div>
</body>
</html>
学科
函数abc()
{
变量a=$('courses1')。值;
$(“k”)。innerHTML='';
新的Ajax.Request(“ajax1.php”{
方法:“post”,
后体:“e=”+a,
未完成:更新\u abc
});
}
功能更新\u abc(要求)
{
var数据=请求响应文本;
$(“k”)。innerHTML='';
$(“k”).innerHTML=数据;
//警报(数据);
}
07/25/2014
将文件添加到主题|
选课
选课
选择主题
选择主题
文件名
上传图片
要上载图像或任何文件,应指定“enctype”
<form method="post" action="filupload.php" enctype="multipart/form-data">
在表单标签中使用enctype=“multipart/form data”如:
<form action="filupload.php" method="post" enctype="multipart/form-data">
感谢大家支持我解决问题,我对php和stack overflow不太熟悉,如何在解决问题时关闭此Q无需删除此问题。另外,请接受回答。:)谢谢问题已解决,请解决我的另一个问题,因为我已经张贴