0

嗨,我有这个需要更改的 php,我复制了我的站点并将其存储在一个名为 m/ 的子目录中,我希望能够将文件从 m/ 目录站点上传到根目录站点。这是脚本的功能:

global $MAX_FILE_SIZE;

    global $MAX_THUMB_HEIGHT;

    global $MAX_THUMB_WIDTH;

    global $DELETE_ORIGIN_IMAGE;

    global $myfile;


    $err = check_err();
    if(!empty($err))
        return edit_profile_form($err);



    /*** Upload logo image*/

    if($_FILES['business_logo'])

    {
        //die($MAX_FILE_SIZE.'x');
        $business_logo=uploadfile("../img/consumer_user/",$_FILES['business_logo'],0,$MAX_FILE_SIZE);
    }

    if($business_logo=='-1')

    {

        $err['upload_logo'] = "<span style=\"color: red;\">- Upload error with <b>Business Logo</b>. Cannot be uploaded due to permission.</span><br>";

    }

    else if($business_logo=='0')

    {

        $err['upload_logo'] = "<span style=\"color: red;\">- Upload error with <b>Business Logo</b>. File type not allowed</span><br>";

    }

    else if($business_logo=='1')

    {

        $err['upload_logo'] = "<span style=\"color: red;\">- Upload error with <b>Business Logo</b>. File size not allowed</span><br>";

    }

    else if($business_logo=='2')

    {

        $business_logo="";

    }

    //echo $business_logo;

    if ($business_logo)

    {

        if($_FILES['business_logo']['name'])

        {

            $myfile=str_replace(" ","_",$_FILES['business_logo']['name']);

            $myfile=time()."_".$myfile;//echo $myfile;

            if ($myfile)

            {

                //Create thumbnail

                for($i=0;$i<count($MAX_THUMB_WIDTH);$i++)

                {

                    $MAX_QUALITY[$i]=$MAX_THUMB_WIDTH[$i]>$MAX_THUMB_HEIGHT[$i]?$MAX_THUMB_WIDTH[$i]:$MAX_THUMB_HEIGHT[$i];

                    thumbnail_images($_FILES['business_logo'],$MAX_THUMB_WIDTH[$i] ,$MAX_THUMB_HEIGHT[$i] ,"../img/consumer_user/","thumb_".$i,$myfile); 

                }

                if($DELETE_ORIGIN_IMAGE)

                {

                    deletefile("../img/consumer_user/".$myfile);

                }

            }

        }

    }
    if(!empty($err))
        return edit_profile_form($err);

正如你所看到的,我试图通过放置明显的 ../ 来摆脱 m/,但它似乎不起作用。

有什么建议吗?谢谢

4

1 回答 1

1

据我所知,访问其他目录没有问题,只要你的用户有足够的文件访问权限。

也许尝试使用完整的文件路径$_SERVER["SCRIPT_FILENAME"]并使用绝对路径保存文件?

于 2013-06-14T10:22:41.913 回答