Fix #414 Unable to download file to nonexistent directory

This commit is contained in:
Kijin Sung 2016-03-29 00:00:40 +09:00
parent 5ed55ff4af
commit 9b5ee1af48

View file

@ -423,6 +423,12 @@ class FileHandler
*/
public static function getRemoteFile($url, $target_filename, $body = null, $timeout = 3, $method = 'GET', $content_type = null, $headers = array(), $cookies = array(), $post_data = array(), $request_config = array())
{
$target_dirname = dirname($target_filename);
if (!Rhymix\Framework\Storage::isDirectory($target_dirname) && !Rhymix\Framework\Storage::createDirectory($target_dirname))
{
return false;
}
$request_config['filename'] = $target_filename;
$success = self::getRemoteResource($url, $body, $timeout, $method, $content_type, $headers, $cookies, $post_data, $request_config);
return $success ? true : false;