douwen9540 2015-03-11 17:57
浏览 254

警告:move_uploaded_file无法打开流:权限被拒绝PHP文件

I am currently working on a booking system. When the admin logs in he/she has to be able to update data.I am trying to upload an image to update an image but every time I try to do that, I get two warning messages. The following are the warning messages that I receive.

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

The following is my PHP code:

        <?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>&nbsp;</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>

Any help would be much appreciated. Thanks very much indeed in advance.

  • 写回答

1条回答 默认 最新

  • dow5001 2015-03-11 19:14
    关注

    Check your permissions on the path /production_images/. That seems like the most likely issue. The path is either not writable by your server user or the path doesn't exist.

    评论

报告相同问题?

悬赏问题

  • ¥15 mmocr的训练错误,结果全为0
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀