我目前正在开发预订系统。当管理员登录时他/她必须能够更新数据。我正在尝试上传图像以更新图像,但每次我尝试这样做时,都会收到两条警告消息。以下是我收到的警告信息。
Warning: move_uploaded_file(../production_images/113.jpg): failed to open stream: Permission denied in /home/www/TheatreWebsite/storeadmin/inventory_edit.php on line 87
Warning: move_uploaded_file(): Unable to move '/tmp/phpDt7qFp' to '../production_images/113.jpg' in /home/www/TheatreWebsite/storeadmin/inventory_edit.php on line 87
以下是我的PHP代码:
<?php
if (isset($_POST['productiontype'])) {
//$pid = mysql_real_escape_string($_POST['thisID']);
$pid = mysqli_real_escape_string($db_con,$_POST['thisID']);
$productionname = mysqli_real_escape_string($db_con,$_POST['productionname']);
$productiontype = mysqli_real_escape_string($db_con,$_POST['productiontype']);
$description = mysqli_real_escape_string($db_con,$_POST['description']);
$q1 = "UPDATE Production SET productionname = '$productionname', productiontype='$productiontype', description='$description' WHERE productionid='$pid'"; $sql = $db_con->query($q1);
if ($_FILES['filefield']['tmp_name'] != "") {
// Place image in the folder
$newname = "$pid.jpg";
echo '<script language="javascript">';
//$pid = mysqli_real_escape_string($db_con,$_POST['thisID']);
echo "alert('$newname')";
echo '</script>';
move_uploaded_file($_FILES['filefield']['tmp_name'], "../production_images/".$newname);
}
}
?>
<?php
// Gather this product's full information for inserting automatically into the edit form below on page
if (isset($_GET['pid'])) {
$targetID = $_GET['pid'];
$sql = "SELECT * FROM Production WHERE productionid='$targetID' LIMIT 1";
$sql = mysqli_query($db_con,$sql);
$productCount = mysqli_num_rows($sql); // count the output amount
if ($productCount > 0) {
while($row = mysqli_fetch_array($sql,MYSQLI_ASSOC)){
$pid = $row["productionid"];
$productionname = $row["productionname"];
$productiontype = $row["productiontype"];
$description = $row["description"];
}
} else {
echo "Sorry that Production doesn't exist.";
exit();
}
}
?>
<!DOCTYPE>
<html>
<head>
<title>Inventory Edit</title>
<link rel="stylesheet" href="css/main_style.css" type="text/css" media="screen"/>
<style>
</style>
</head>
<div align="right" style="margin-left:30px"> <a href="inventory_list.php#inventoryForm">+ NEW INVENTORY ITEM</a></div>
<form action="inventory_edit.php" enctype="multipart/form-data" name="myForm" id="myForm" method="post" >
<table width="90%" border="0" cellspacing="0" cellpadding="6">
<tr>
<td width="20%">Production Name</td>
<td width="80%"><label>
<input name="productionname" type="text" id="productionname" size="64" value="<?php echo $productionname; ?>"/>
</label></td>
</tr>
<tr>
<td>Production Type</td>
<td><label>
<select name="productiontype" id="productiontype">
<option value="<?php echo $productiontype;?>"><?php echo $productiontype;?> </option>
<option value="Comedy">Comedy</option>
<option value="Drama">Drama</option>
<option value="Opera">Opera</option>
<option value="Romance">Romance</option>
<option value="Fantasy">Fantasy</option>
<option value="Horror">Horror</option>
</select>
</label></td>
</tr>
<tr>
<td>Production Description</td>
<td><label>
<textarea name="description" id="description" cols="64" rows="5"><?php echo $description;?></textarea>
</label></td>
</tr>
<td>Product Image</td>
<td><label>
<input type="file" name="filefield" id="filefield"/>
</label>
</td>
</tr>
<tr>
<td> </td>
<td><label>
<input name="thisID" type="hidden" value="<?php echo $targetID; ?>" />
<input type="submit" name="button" id="button" value="Make Changes" />
</label></td>
</tr>
</table>
</form>
</div>
</div>
<br/>
<br/>
</div>
<div id="footer">
<div id=footerwrap>
<div id="foot1">
<ul class="a">
</ul>
</div>
</div>
</div>
<!--here is where some javascrip goes regarding the navigation main menu*-->
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="js/general.js"></script>
</body>
</html>
非常感谢任何帮助。非常感谢提前。
答案 0 :(得分:0)
检查路径/production_images/
上的权限。这似乎是最可能的问题。该路径要么不是您的服务器用户可写,要么该路径不存在。