简体   繁体   English

尝试在我的实时网站上上传文件时,我遇到了move_uploaded_file错误

[英]I am getting error for move_uploaded_file while trying to upload file on my live site

here is the error 这是错误

Warning: move_uploaded_file() [function.move-uploaded-file]: open_basedir restriction in effect. 警告:move_uploaded_file()[function.move-uploaded-file]:open_basedir限制有效。 File(C:\\Windows\\Temp\\php205.tmp) is not within the allowed path(s): (E:\\inetpub\\vhosts\\astradingcompany.org\\httpdocs) in E:\\inetpub\\vhosts\\astradingcompany.org\\httpdocs\\mycar\\postaddata.php on line 26 文件(C:\\ Windows \\ Temp \\ php205.tmp)不在允许的路径内:E:\\ inetpub \\ vhosts \\ astradingcompany.org \\ httpdocs中的(E:\\ inetpub \\ vhosts \\ astradingcompany.org \\ httpdocs) \\ mycar \\ postaddata.php在第26行

Warning: move_uploaded_file(mycar/uploads/car001.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in E:\\inetpub\\vhosts\\astradingcompany.org\\httpdocs\\mycar\\postaddata.php on line 26 警告:move_uploaded_file(mycar / uploads / car001.jpg)[function.move-uploaded-file]:无法打开流:E:\\ inetpub \\ vhosts \\ astradingcompany.org \\ httpdocs \\ mycar \\ postaddata中没有此类文件或目录。第26行的php

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\\Windows\\Temp\\php205.tmp' to 'mycar/uploads/car001.jpg' in E:\\inetpub\\vhosts\\astradingcompany.org\\httpdocs\\mycar\\postaddata.php on line 26 警告:move_uploaded_file()[function.move-uploaded-file]:无法将E:\\ inetpub \\ vhosts \\ astradingcompany中的'C:\\ Windows \\ Temp \\ php205.tmp'移动到'mycar / uploads / car001.jpg'。第26行的org \\ httpdocs \\ mycar \\ postaddata.php

here is the code sippet 这是代码段

if ($_FILES['file']['error'] === UPLOAD_ERR_OK) 
     {
        if((($_FILES['file']['type'] == 'image/gif') 
            || ($_FILES["file"]['type'] == 'image/jpg') 
            || ($_FILES["file"]['type'] == 'image/png')
            || ($_FILES["file"]['type'] == 'image/jpeg')) 
            //&& ($_FILES["file"]['size'] < 20000) 
            && (in_array($extensions, $allowedextensions)))                                                                                                      
            {                                                       
             if (file_exists("mycar/uploads/". $_FILES['file']['name']))
                {
                $msg =  $_FILES['file']['name']. "<b> <font face='Verdana, Geneva, sans-serif' color='red'>File Already Exists</font></b>";
                header('Location:postad.php?msg='.$msg);
                }
                else
                    {
//                      $filename = "mycar/uploads/" .$_FILES['file']['name'];
                    move_uploaded_file($_FILES['file']['tmp_name'], "mycar/uploads/" . $_FILES['file']['name']);
//                  is_uploaded_file($_FILES['file']['tmp_name']), "uploads/" . $_FILES['file']['name'];
//                  is_uploaded_file($_FILES['file']['tmp_name'],"uploads/" . $_FILES['file']['name']);
//                  copy($_FILES['file']['tmp_name'], $uploaddatafile);
//                  copy($_FILES['file']['tmp_name'], $filename);

create a directory named uploads and assure that it is indeed writable by the server with necessary chmod priveleges. 创建一个名为uploads的目录,并确保该目录确实可以由具有必要chmod特权的服务器写入。 In some instances according on server configuration the directory may need sufficient ownership as well such as www-data 在某些情况下,根据服务器配置,目录可能还需要足够的所有权,例如www-data

Please check this How to fix PHP upload file inherit permissions error using Windows IIS Server . 请检查此如何使用Windows IIS Server修复PHP上传文件继承权限错误 Thanks to Garon, for me also same issue was there. 多亏加伦,对我来说,同样的问题也在那里。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM