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
) { if (($buffer =
$this->
fread(min($buffersize,
$bytesleft))) === false
|| ($byteswritten =
fwrite($fp_dest,
$buffer)) === false
|| ($byteswritten === 0
)) { throw new Exception($buffer === false ? 'not enough data to read' : 'failed to write to destination file, may be not enough disk space'
);
} $bytesleft -=
$byteswritten;
} fclose($fp_dest);
$attachment =
$dest;
}