throw new Exception('failed to read attachment data'
);
} // assume directory path is given
} else { // set up destination path
$dir =
rtrim(str_replace(array
('/', '\\'
), DIRECTORY_SEPARATOR,
$this->getid3->option_save_attachments
), DIRECTORY_SEPARATOR
);
if (!
is_dir($dir) || !getID3::
is_writable($dir)) { // check supplied directory
throw new Exception('supplied path ('.
$dir.') does not exist, or is not writable'
);
} $dest =
$dir.DIRECTORY_SEPARATOR.
$name.
($image_mime ? '.'.getid3_lib::
ImageExtFromMime($image_mime) : ''
);
// create dest file
if (($fp_dest =
fopen($dest, 'wb'
)) == false
) { throw new Exception('failed to create file '.
$dest);
} // copy data
$this->
fseek($offset);
$buffersize =
($this->data_string_flag ?
$length :
$this->getid3->
fread_buffer_size());
$bytesleft =
$length;
while ($bytesleft > 0
) {