简体   繁体   English

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

[英]Warning: move_uploaded_file failed to open stream: Permission denied PHP file

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代码:

        <?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. 确实非常感谢。

Check your permissions on the path /production_images/ . 检查您在/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. 服务器用户无法写入该路径,或者该路径不存在。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 PHP警告:move_uploaded_file():无法移动/无法打开流:权限被拒绝 - PHP Warning: move_uploaded_file(): Unable to move/failed to open stream: Permission denied php 文件上传错误警告 move_uploaded_file 无法打开 stream 权限被拒绝 - php file upload error warning move_uploaded_file failed to open stream permission denied in PHP / IIS copy()/ move_uploaded_file()无法打开流:权限被拒绝警告 - PHP/IIS copy()/move_uploaded_file() failed to open stream: Permission denied Warning move_uploaded_file 无法打开 stream:权限被拒绝 - Mac - move_uploaded_file failed to open stream: Permission denied - Mac move_uploaded_file无法打开流和权限被拒绝错误 - move_uploaded_file failed to open stream and Permission denied error move_uploaded_file 无法打开流:权限被拒绝 Mac - move_uploaded_file failed to open stream: Permission denied Mac move_uploaded_file给出:无法打开流:权限被拒绝 - move_uploaded_file gives: failed to open stream: Permission denied 上传文件警告:move_uploaded_file(../ view / pictureswhy.PNG):无法打开流:权限被拒绝 - Upload file Warning: move_uploaded_file(../view/pictureswhy.PNG): failed to open stream: Permission denied 警告:move_uploaded_file(../ project / discussdesk.xlsx):无法打开流:权限被拒绝 - Warning: move_uploaded_file(../project/discussdesk.xlsx): failed to open stream: Permission denied 警告:move_uploaded_file(** Path **):无法打开流:权限被拒绝 - Warning: move_uploaded_file(**Path**): failed to open stream: Permission denied in
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM