Home > Backend Development > PHP Tutorial > 请问为何文件传不到阿里云上,这段代码哪里不对

请问为何文件传不到阿里云上,这段代码哪里不对

WBOY
Release: 2016-06-06 20:41:45
Original
1105 people have browsed it

<code>    function uploadopenossserver($filer,$ossid=1,$type=0){
        global $empire,$dbtbpre,$public_r,$ftp_r,$oss_r,$incftp;            
            $pr=getossserverinfo($ossid);       
            @include(ECMS_PATH."e/extend/aliyun/oss/sdk.class.php");
            if(!$pr[hostname]){
                    if($pr[osstype]=='1') { $pr[hostname]='oss-cn-hangzhou.aliyuncs.com'; }
                    elseif($pr[osstype]=='2'){ $pr[hostname]='oss-cn-hangzhou-internal.aliyuncs.com'; }
                    elseif($pr[osstype]=='3'){ $pr[hostname]='oss-cn-qingdao.aliyuncs.com'; }
                    elseif($pr[osstype]=='4'){ $pr[hostname]='oss-cn-qingdao-internal.aliyuncs.com'; }
                    elseif($pr[osstype]=='5'){ $pr[hostname]='oss-cn-beijing.aliyuncs.com'; }
                    elseif($pr[osstype]=='6'){ $pr[hostname]='oss-cn-beijing-internal.aliyuncs.com'; }
                    elseif($pr[osstype]=='7'){ $pr[hostname]='oss-cn-hongkong.aliyuncs.com'; }
                    elseif($pr[osstype]=='8'){ $pr[hostname]='oss-cn-hongkong-internal.aliyuncs.com'; }
                    elseif($pr[osstype]=='9'){ $pr[hostname]='oss-cn-shenzhen.aliyuncs.com'; }
                    else{ $pr[hostname]='oss-cn-hangzhou-internal.aliyuncs.com'; } 
            }
            else{
                printerror2("OSS节点选择错误,无法同步");
            }   

            $oss=new ALIOSS($pr[Access_Key_ID],$pr[Access_Key_Secret],$pr[hostname]);
            $oss->set_debug_mode(FALSE);

        foreach ($filer as $file){
            $object=str_replace(ECMS_PATH,'',$file);
            //$truefile=RTruePathOpen($pr[bucket],$filenopath);
            $oss->upload_file_by_file($pr[bucket],$object,$file);
            //上传文件
            print_r($oss);
        }
        //退出OSS
        $oss=NULL;
        return true;                

}
</code>
Copy after login
Copy after login

回复内容:

<code>    function uploadopenossserver($filer,$ossid=1,$type=0){
        global $empire,$dbtbpre,$public_r,$ftp_r,$oss_r,$incftp;            
            $pr=getossserverinfo($ossid);       
            @include(ECMS_PATH."e/extend/aliyun/oss/sdk.class.php");
            if(!$pr[hostname]){
                    if($pr[osstype]=='1') { $pr[hostname]='oss-cn-hangzhou.aliyuncs.com'; }
                    elseif($pr[osstype]=='2'){ $pr[hostname]='oss-cn-hangzhou-internal.aliyuncs.com'; }
                    elseif($pr[osstype]=='3'){ $pr[hostname]='oss-cn-qingdao.aliyuncs.com'; }
                    elseif($pr[osstype]=='4'){ $pr[hostname]='oss-cn-qingdao-internal.aliyuncs.com'; }
                    elseif($pr[osstype]=='5'){ $pr[hostname]='oss-cn-beijing.aliyuncs.com'; }
                    elseif($pr[osstype]=='6'){ $pr[hostname]='oss-cn-beijing-internal.aliyuncs.com'; }
                    elseif($pr[osstype]=='7'){ $pr[hostname]='oss-cn-hongkong.aliyuncs.com'; }
                    elseif($pr[osstype]=='8'){ $pr[hostname]='oss-cn-hongkong-internal.aliyuncs.com'; }
                    elseif($pr[osstype]=='9'){ $pr[hostname]='oss-cn-shenzhen.aliyuncs.com'; }
                    else{ $pr[hostname]='oss-cn-hangzhou-internal.aliyuncs.com'; } 
            }
            else{
                printerror2("OSS节点选择错误,无法同步");
            }   

            $oss=new ALIOSS($pr[Access_Key_ID],$pr[Access_Key_Secret],$pr[hostname]);
            $oss->set_debug_mode(FALSE);

        foreach ($filer as $file){
            $object=str_replace(ECMS_PATH,'',$file);
            //$truefile=RTruePathOpen($pr[bucket],$filenopath);
            $oss->upload_file_by_file($pr[bucket],$object,$file);
            //上传文件
            print_r($oss);
        }
        //退出OSS
        $oss=NULL;
        return true;                

}
</code>
Copy after login
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template