我正在使用CodeIgniter在AWS S3上上传图片。然而,在我将图像上传到S3之前,我想调整它的大小。我正在使用本机CodeIgniter图像处理库来调整上传时存储在tmp文件夹中的图像,然后将其推送到S3。然而,在我调整了图像大小后,我想获得调整大小的图像的新文件大小,但它在上传之前不断返回原始图像大小(使用CI文件库或本机PHP文件大小功能)
我的代码如下:
// set upload details
$upload_details = array(
'filename' => $sanitized_filename,
'location' => $_FILES["file"]['tmp_name'],
'size' => $_FILES["file"]['size'],
'extension' => end(explode(".", $_FILES["file"]["name"])),
'mime_type' => get_file_mime_type($_FILES['file']['tmp_name']),
's3_object_key' => $s3_upload_path . $s3_filename,
's3_upload_result' => FALSE
);
// check if image we are uploading and if image options have been set
$image_size = getimagesize($upload_details['location']);
if($image_size)
{
$current_image_width = $image_size[0];
$current_image_height = $image_size[1];
if($current_image_width > $image_options['width'] || $current_image_height > $image_options['height'])
{
// specify image resize options
$config['image_library'] = 'gd2';
$config['source_image'] = $upload_details['location'];
$config['maintain_ratio'] = TRUE;
$config['width'] = $image_options['width'];
$config['height'] = $image_options['height'];
// load image manipulation library with config options
$ci->load->library('image_lib', $config);
if ( ! $ci->image_lib->resize())
{
showhouse_log(MY_Log::KERROR, $ci->image_lib->display_errors());
}
// update size details of new resized image
$ci->load->helper('file');
$info = get_file_info($upload_details['location'], array('size'));
$new_file_size = filesize($upload_details['location']);
$upload_details['size'] = $new_file_size;
}
}
为什么这个没有在tmp目录中获取新文件大小的任何想法,即使我可以看到文件大小在flie系统中的tmp文件上发生了变化?