Php 脚本无法打开流

Php 脚本无法打开流,php,stream,Php,Stream,我正在尝试设置上载站点,但无法获取上载文件的脚本。(上载文件夹的所有权限均设置为777。)我继续收到以下错误: Warning: move_uploaded_file(/var/chroot/home/content/44/9976344/html/tech/filemanager/uploads/Ace_planning_instructions.docx) [function.move-uploaded-file]: failed to open stream: No such file o

我正在尝试设置上载站点,但无法获取上载文件的脚本。(上载文件夹的所有权限均设置为777。)我继续收到以下错误:

Warning: move_uploaded_file(/var/chroot/home/content/44/9976344/html/tech/filemanager/uploads/Ace_planning_instructions.docx) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/content/44/9976344/html/tech/tech/js/upload.php on line 72

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpo89pGR' to '/var/chroot/home/content/44/9976344/html/tech/filemanager/uploads/Ace_planning_instructions.docx' in /home/content/44/9976344/html/tech/tech/js/upload.php on line 72
Error! Most likely upload directory doesn't have writable permissions or you didn't set it up correctly. 
我可以做些什么来修复或解决这些错误


这是我的密码:

<?php
require_once("../includes/dbconnect.php"); //Load the settings
require_once("../includes/functions.php"); //Load the functions 



// Work-around for setting up a session because Flash Player doesn't send the cookies
if (isset($_POST["PHPSESSID"])) {
    session_id($_POST["PHPSESSID"]);
}
session_start();

$upload_dir = (!empty($_POST["upload_dir"]))?strip_tags(str_replace("'","`",$_POST["upload_dir"])):getUploadDir($_SESSION["idUser"]);

if($demo){
    echo "Uploads disabled in demo!";
} else { 
$q="SELECT id,parentID FROM folders WHERE name='".$upload_dir."'";
$res=mysql_query($q);
$rrr=mysql_fetch_assoc($res);
$folderID=$rrr["id"];

if($rrr["parentID"]!=0){
    $q2="SELECT name FROM folders WHERE id='".$rrr["parentID"]."'";
    $res2=mysql_query($q2);
    $rrr2=mysql_fetch_assoc($res2);
    $tmpStr=$rrr2["name"]."/";
} else { $tmpStr = ""; } 

$uploadfile = $_SERVER['DOCUMENT_ROOT'].$script_dir.$tmpStr.$upload_dir."/".(str_replace(" ","_",$_FILES['Filedata']['name'])); 

        $FileNametmp = $_FILES['Filedata']['name'];
        $fileNamePartstmp = explode(".", $FileNametmp);
        $counter2 = count($fileNamePartstmp)-1;
        $fileExtensiontmp = strtolower($fileNamePartstmp[$counter2]); // Estension (part behind last dot)
        $title=$FileNametmp;
        $fsize = filesize($_FILES['Filedata']['tmp_name']);
        $fileEXT = strtoupper($fileExtensiontmp);
        //get limits for current user.
        $sSQL = "SELECT id,username,filesize,quota,extensions FROM users WHERE id='".$_REQUEST["user"]."'";
        $result = mysql_query($sSQL) or die("err: " . mysql_error().$sSQL);
        if($row = mysql_fetch_assoc($result)){
        $max_filesize = $row["filesize"];
        $extensionsArr = explode(",",$row["extensions"]);
            $sql2="SELECT SUM(size) userQuota FROM files WHERE userID='".$_REQUEST["user"]."'";
            $result2=mysql_query($sql2) or die("error getting user files sizes");
            $rr=mysql_fetch_assoc($result2);
        $max_quota = $row["quota"];
        $current_quota = $rr["userQuota"];
        }

        $upload=false;
        //validations
        if($current_quota<($max_quota * 1024 * 1024)){
            if($current_quota  + $fsize <=($max_quota * 1024 * 1024)){
                if($fsize<=($max_filesize * 1024 * 1024)){

                    for($i=0;$i<count($extensionsArr);$i++){
                        if($extensionsArr[$i]==$fileEXT){
                            $upload=true;
                        }
                    } 


                    if($upload){
                        //everything ok, upload file.
                        //if($fileEXT=="EXE" || $fileEXT=="COM" || $fileEXT=="BAT" || $fileEXT=="HTM" || $fileEXT=="HTML" || $fileEXT=="PHP" || $fileEXT=="JS"){
                        //addLog($_SESSION["idUser"],"forbidden file upload $title ");
                        //$msg = "Such files are forbidden in demo version.";
                        //} else {
                        //$filePath=uploadFile($_FILES['file'], $upload_dir.$title."_".$_SESSION["idUser"].".".$fileExtensiontmp);
                        if(move_uploaded_file( $_FILES['Filedata']['tmp_name'] , $uploadfile )){
                        $sSQL="INSERT INTO files (title,path,size,extension,userID,catID,dateUploaded) VALUES ('".$title."','".$script_dir.$tmpStr.$upload_dir."/".str_replace(" ","_",$_FILES['Filedata']['name'])."','".$fsize."','".$fileExtensiontmp."','".$_REQUEST["user"]."','".$folderID."',NOW())";
                        mysql_query($sSQL) or die("Invalid query: " . mysql_error() . " - $sSQL");
                        addLog($_REQUEST["user"],"Uploaded file $title ");
                        $msg = "You have successfully uploaded file $title ";

                            $notice = sendNotice('notify_upload');
                            if($notice){
                            //send notice to system mail
                            send_mail("New file uploaded!", getUser($_REQUEST["user"])." have successfully uploaded file $title");
                            }

                        } else { 
                        $msg = "Error! Most likely upload directory doesn't have writable permissions or you didn't set it up correctly. ";
                        }
                        //}
                    } else {
                        $msg = "Not allowed file extension $fileEXT! ";
                        addLog($_REQUEST["user"],"Error! Tried to upload $title. Got \'Not allowed file extension\' ");
                    }

                } else {
                $msg = "File size is larger than you maximum allowed size limit.";
                addLog($_REQUEST["user"],"Error! Tried to upload $title. Got \'File size is larger than you maximum allowed size limit.\' ");
                }
            } else {
            $msg = "Not enough space left for you on the server. Try deleting some files.";
            addLog($_REQUEST["user"],"Error! Tried to upload $title. Got \'Not enough space left for you on the server. Try deleting some files.\' ");
            }
        } else { 
        $msg = "Your upload quota has been reached. Try deleting some files.";
        addLog($_REQUEST["user"],"Error! Tried to upload $title. Got \'Your upload quota has been reached. Try deleting some files.\' ");
        }

    //send_mail("Email Notify",$msg);
    echo $msg;
}

exit(0);
?>

据我所知,您正在将上载复制到错误的目录

“/var/chroot/home/content/44/9976344/html/tech/filemanager/uploads/”和“/home/content/44/9976344/html/tech/filemanager/uploads/”如果其中一个是最有可能的符号链接,则它们不相同。使用路径“/home/content/44/9976344/html/tech/filemanager/uploads/”而不是您之前使用的路径“/var/chroot/home/content/44/9976344/html/tech/filemanager/uploads/”。仅包含有关其链接到的文件的信息

你明白例外情况吗
没有这样的文件或目录
听起来像是在错误的位置查找文件。您可以使用
是否可读($filePath)
检查文件路径是否有效(并且可读)。您可以发布与此一起使用的表单吗?或者如果不是,这篇文章是否使用了多部分/表单数据编码?我确实理解这个例外。我运行install.php脚本并在主机中创建目录,所有目录都具有777访问权限。我想从我的桌面上传一个文件Alex,你这是什么意思??我使用的程序是Advanced File Manager有人能更好地解释如何修改上面的upload.php代码以使其正常工作吗>