Permission for Saved Images from URL

Dir permission:

mkdir($newPath, 0775);

File permission: (writable)

//下載新的圖檔
$retrieved_file = @file_get_contents($img_url, false, $context);
if($retrieved_file != false){
	$result = file_put_contents($newFileName, $retrieved_file);

	//Set permission
	$old = umask(0);
	chmod($newFileName, 0664);

	$new_url = BASE_URL . 'storage/confluence/' . $confluence_id . '/' . $new_name;

	//Replace src value in HTML
	$img->setAttribute('src', $new_url);
}