简体   繁体   English

如何用两个不同的文件夹上传两个文件?

[英]How to upload two files with two different folders?

I'm trying to upload two files with two different folders, but it is actually uploading the only second file. 我正在尝试上传具有两个不同文件夹的两个文件,但实际上是在上传唯一的第二个文件。 how to resolve this one? 该如何解决呢?

       private function _referal_image1( $type1, $type2, $img ) {
            $tempname1 = __static__ .'referral_logo'. __ds__ . $type1;
            $tempname2 = __static__ .'referral_background'. __ds__ . $type2;

            move_uploaded_file($img, $tempname1);
            move_uploaded_file($img, $tempname2);

            $file_name1 = 'referral_logo'.__ds__.$type1;
            $file_name2 = 'referral_background'.__ds__.$type2;

            $combine = array($file_name1, $file_name2);
            return $combine;
        }

You have this line twice: 您有两次此行:

move_uploaded_file($img, $tempname1);
move_uploaded_file($img, $tempname1);

You can't move the same file twice. 您不能两次移动同一文件。 You need to copy the file the 2nd time 您需要第二次复制文件

move_uploaded_file($img, $tempname1);
copy($tempname1 , $tempname2);

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

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