imagejpeg 不适用于生产服务器

imagejpeg not working on production server

我在 WordPress 中有以下功能,可以抓取组中所有用户的照片,将它们拼接在一起并创建合成图像,然后将其保存在主题文件夹中。

这在我的开发服务器上完美运行,但在生产服务器上没有任何作用。

这是权限问题吗?开发服务器是 运行 php 5.5.12,实时服务器是 运行 5.5.23,所以这不会造成问题(我不认为 imagejpeg 已被弃用?)。两者都是 运行 最新版本的 WordPress。开发服务器是 WAMP,生产服务器是 LAMP.

函数如下:

function group_thumbnail($post_id) {

        // Generates a composite thumbnail, a la Spotify playlists, to use in the group layout.

                $user_portraits = array();
                if(!empty($_POST['wpcf']['allowed-users'])) :
                    $allowed_users = $_POST['wpcf']['allowed-users']; // For the back end
                else : 
                    $allowed_users = get_post_meta($post_id,'wpcf-allowed-users',false); // For the front end
                endif;

                $allowed_users = sort_pictures_by_name($allowed_users);

                $group_size = count($allowed_users);

                if($group_size < 4) : $limit=1; $row_size = 1; endif;
                if($group_size >= 4 && $group_size < 9) : $limit=4; $row_size = 2; endif;
                if($group_size >= 9 && $group_size < 16) : $limit=9; $row_size = 3; endif;
                if($group_size >= 16) : $limit=16; $row_size = 4; endif;
                $square_size = 200/$row_size;
                foreach ($allowed_users as $u_id) :
                    $u_portrait=get_user_meta($u_id, 'wpcf-portrait', true); 
                    $u_file = imagecreatefromjpeg($u_portrait);
                    $user_portraits[] = $u_file;
                endforeach;
                $group_image = imagecreatetruecolor ( 200 , 200 );
                $postion = array('x'=>0,'y'=>0);
                for($i=0; $i<$limit; $i++) :    
                    if($i % $row_size == 0 && $i<>0) : 
                        $postion['x']=0;
                        $postion['y']+=$square_size;
                    endif;  
                    imagecopyresized($group_image,$user_portraits[$i],$postion['x'],$postion['y'],0,0,$square_size,$square_size,180,180);
                    imagedestroy($user_portraits[$i]);
                    $postion['x']+=$square_size;
                endfor;         
                // Output and free from memory
                imagejpeg($group_image,get_template_directory().'/img/groups/'.$post_id.'.jpg',60);
                imagedestroy($group_image);
                clearstatcache();

    }

最后很简单 - 生产服务器上的文件夹不可写。通过FTP.

快速整理