0

アップロード サイトをセットアップしようとしていますが、ファイルをアップロードするスクリプトを取得できません。(アップロード フォルダーのすべてのアクセス許可は 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);
?>
4

1 に答える 1

0

ご覧のとおり、アップロードを間​​違ったディレクトリ「/var/chroot/home/content/44/9976344/html/tech/filemanager/uploads/」および「/home/content/44/9976344/html/tech」にコピーしています/filemanager/uploads/" のうちの 1 つがシンボリック リンクである場合、それらは同じではありません。「/var/chroot/home/content/44/9976344/html/tech/filemanager/uploads」の代わりに「/home/content/44/9976344/html/tech/filemanager/uploads/」パスを使用します/」。シンボリック リンクには、リンク先のファイルに関する情報のみが含まれます。

于 2013-07-30T14:10:46.663 に答える